Don't copy mutation branches unecessarily #48094
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Performance "Speed up navigation in traits menu"
Purpose of change
I've never experienced this menu to be terribly slow, but @KorGgenT has often complained about it in the past.
I profiled it and saw that checking if traits conflict via
has_same_trait_type
was taking a huge percentage of the time.Describe the solution
My profiling showed that most of the overhead from
has_same_trait_type
was due toget_mutations_in_type
, and most of that due to constructing mutations branches. So, stop taking uneccessary copies, and use references.Describe alternatives you've considered
This is about a five minute fix, and perf is telling me it's a huge improvement, so I'm happy to leave it here.
Testing
perf record -g -p PID
when in the traits menu, scroll around and select a few traits.Additional context
Before:
After: