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

Conversation

@jonahwilliams
Copy link
Contributor

@jonahwilliams jonahwilliams commented Dec 7, 2023

I'm not exactly sure why, but this seems to stop the allocation of capture labels in release mode.

Fixes flutter/flutter#138908

@jonahwilliams jonahwilliams marked this pull request as ready for review December 7, 2023 16:55
@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.

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.

Copy link
Member

@bdero bdero left a comment

Choose a reason for hiding this comment

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

LGTM

@stuartmorgan-g
Copy link
Contributor

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); \
Copy link
Contributor

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?

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 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);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question here.

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 8, 2023
@auto-submit auto-submit bot merged commit e9cb19f into flutter:main Dec 8, 2023
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.

[Impeller] capture client labels are still allocated in release mode.

4 participants