-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] dont allocate capture strings in release mode. #48760
[Impeller] dont allocate capture strings in release mode. #48760
Conversation
|
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. |
gaaclarke
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know what is happening, there must be a place where someone is calling these functions with a char* so even though it is a const std::string& it will create a std::string which copies the value so that it can pass a reference to that. std::string_view will never copy. You can use a std::string_view here. It's probably faster than const std::string_view& considering it's so small and avoids another level of indirection.
Test exempt: No logical change, the effects will be measured in a benchmark.
bdero
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
test-exempt: code refactor with no semantic change (Do we have a benchmark that would catch a regression here though?) |
| } \ | ||
| FML_DCHECK(element_ != nullptr); \ | ||
| \ | ||
| std::string label_clone = std::string(label); \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not push the use of string_view further into the stack so callers don't have to make copies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could. I decided to stop here because the rest of this is debug only is compiled out for profile/release modes.
| } | ||
|
|
||
| auto new_capture = Capture(label); | ||
| std::string label_copy = std::string(label); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question here.
|
The benchmark I use to measure these smaller optimziations is https://flutter-flutter-perf.skia.org/e/?queries=sub_result%3D90th_percentile_frame_rasterizer_time_millis%26sub_result%3Daverage_frame_rasterizer_time_millis%26test%3Dcomplex_layout_scroll_perf_ios__timeline_summary&selected=commit%3D38127%26name%3D%2Carch%3Dintel%2Cbranch%3Dmaster%2Cconfig%3Ddefault%2Cdevice_type%3DiPhone_11%2Cdevice_version%3Dnone%2Chost_type%3Dmac%2Csub_result%3Daverage_frame_rasterizer_time_millis%2Ctest%3Dcomplex_layout_scroll_perf_ios__timeline_summary%2C Its probably too much noise for us to identify individual regressions, but by landing these sorts of improvements we've been able to gradually drive this down over time. |
…139831) flutter/engine@7dc51b8...e9cb19f 2023-12-08 [email protected] [Impeller] dont allocate capture strings in release mode. (flutter/engine#48760) 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
I'm not exactly sure why, but this seems to stop the allocation of capture labels in release mode.
Fixes flutter/flutter#138908