Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@jonahwilliams
Copy link
Contributor

Most of the time we are passing an rvalue into this functions anyway, so in theory moving should be faster. Right?

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie or stuartmorgan on the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be a std::unique_ptr too.

Imagine this case:

size_t Foo::bar() {
  BufferView view = GenerateBufferView();
  binder_->BindResource(stage_, slot_, metadata_, view);
  return view.GetSize();
}

The linter won't complain about an accidental copy because it is used after the copy. That wouldn't be possible with the std::unique_ptr.

size_t Foo::bar() {
  std::unique_ptr<BufferView> view = GenerateBufferView();
  binder_->BindResource(stage_, slot_, metadata_, std::move(view)); // move required
  return view->GetSize();  // crash!
}

case ShaderStage::kVertex:
vertex_bindings.buffers[slot.ext_res_0] = {
.slot = slot, .view = BufferResource(metadata, view)};
.slot = slot, .view = BufferResource(metadata, std::move(view))};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm reading the code correctly, this used to be a copy here, but now is a move which should be faster.

Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you just want to follow the pattern you had in the other PR of having explicit Clone for BufferView?

@jonahwilliams
Copy link
Contributor Author

I do not want to use unique_ptr because adding more heap allocations is going to be counter productive to performance.

But making the type (mostly) move only seems like a good idea. I will give that a shot

@jonahwilliams
Copy link
Contributor Author

I tried making it move only in #48630

The problem is that BufferView is placed directly on a VertexBuffer and directly in Command. So all of those types need to be made move only as wel. That's a bit more than I want to do at once, though making Cmd move only would eventually let us fix the style guide violation of add command - so its probably worth doing.

Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM assuming we have help from the linter if we introduce accidental copies and we are seeing performance benefits in some microbenchmarks.

The references made it impossible to get copies wrong, but also were suboptimal in the case where we could actually pass ownership. I'm willing to give this a shot.

case ShaderStage::kFragment:
fragment_bindings.buffers[slot.ext_res_0] = {
.slot = slot, .view = BufferResource(metadata, view)};
.slot = slot, .view = BufferResource(metadata, std::move(view))};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you accidentally omit the std::move here, we get a linter failure right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not :(

@jonahwilliams
Copy link
Contributor Author

I think for move only, we should start with Command and work our way down, that would be easier than going bottom up.

@Hixie
Copy link
Contributor

Hixie commented Dec 4, 2023

test-exempt: code refactor with no semantic change

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 4, 2023
@auto-submit auto-submit bot merged commit cb133d4 into flutter:main Dec 4, 2023
@jonahwilliams jonahwilliams deleted the move_when_cmd_binging branch December 4, 2023 23:54
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 5, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 5, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 5, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Dec 5, 2023
…139536)

flutter/engine@de0ba84...f43ef6c

2023-12-05 [email protected] Roll Dart SDK from a1b67665b3a3 to 9c74645153ca (1 revision) (flutter/engine#48648)
2023-12-05 [email protected] [Impeller] Remove impeller::Path copy constructor. (flutter/engine#48616)
2023-12-04 [email protected] [Impeller] Move BufferView/Texture/Sampler when binding. (flutter/engine#48628)
2023-12-04 [email protected] Roll Skia from cbd2cf40d63b to d37625f80ac0 (1 revision) (flutter/engine#48643)
2023-12-04 [email protected] Add `flutter` prefix to import (flutter/engine#48617)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App e: impeller

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants