Avoid unnecessary copy in ClassDB::get_property_list#108504
Merged
Repiteo merged 1 commit intogodotengine:masterfrom Sep 18, 2025
Merged
Avoid unnecessary copy in ClassDB::get_property_list#108504Repiteo merged 1 commit intogodotengine:masterfrom
ClassDB::get_property_list#108504Repiteo merged 1 commit intogodotengine:masterfrom
Conversation
Contributor
|
Did you benchmark in release mode? The temporary struct copying here might be optimized and the overhead shouldn't be so noticeable if compiler is smart enough. |
Member
|
The compiler isn't allowed to make this kind of optimization. It's a good idea to test in release mode but i don't expect this to perform worse there. |
Contributor
Author
Good catch, I forgot that I hadn't switched my compiler settings back over. Using optimize=speed_trace: I just ran these back to back in one run each, so the slow first one is probably some sort of cache warmup. Seems like a similar level of speed up. |
Ivorforce
approved these changes
Jul 11, 2025
Contributor
|
Thanks! |
ClassDB::get_property_list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I was poking around the Alloc > Duplicate benchmark and noticed that there's an unnecessary copy happening in
ClassDB::get_property_list.validate_propertymust be run on a copy of thePropertyInfo, but a copy has to be made duringpush_backanyways, so we can rearrange things a bit and only perform one copy instead of two.I ran the Alloc > Duplicate benchmark nine times for each and dropped the top two and bottom two of each:
It's only a ~6.5% speedup, but it's a pretty core function so it seemed worth a PR.