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

Conversation

@jonahwilliams
Copy link
Contributor

This improves the performance of command encoding when there is no debugger attached. most labels are const char*, and so by accepting a string_view we can avoid actually creating a string if validations are disabled.

@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 "@test-exemption-reviewer" in 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.


void CommandEncoderVK::PushDebugGroup(const char* label) const {
void CommandEncoderVK::PushDebugGroup(std::string_view label) const {
if (!HasValidationLayers()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is basically the improvement, since the labels are invisible if there are no validation errors, moving the allocation below means most of the time (benchmarks) they wont even be allocated.

std::string label_copy(label);
vk::DebugUtilsLabelEXT label_info;
label_info.pLabelName = label;
label_info.pLabelName = label_copy.c_str();
Copy link
Member

Choose a reason for hiding this comment

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

You should be able to just use the label directly.

label_info.pLabelName = label.data();

Having an extra copy on the stack isn't really helping.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh duh, thanks!

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!

@matanlurey
Copy link
Contributor

test-exempt: non-semantic refactor (reduces string allocation).

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 20, 2024
@auto-submit auto-submit bot merged commit 53a2436 into flutter:main Jan 20, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 20, 2024
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
Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants