-
-
Notifications
You must be signed in to change notification settings - Fork 620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In generated methods, only allocate the method StringName the first time #1176
Conversation
9fa3590
to
01a315d
Compare
Should this be applied to godot-cpp/binding_generator.py Lines 1454 to 1468 in d627942
Getting |
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.
The same probably should be done to the get_singleton
(internal::gdextension_interface_global_get_singleton
) and utility functions (internal::gdextension_interface_variant_get_ptr_utility_function
).
As I commented on the issue, this should be moved inside the godot-cpp/binding_generator.py Lines 1491 to 1496 in d627942
Because in the |
01a315d
to
efc16b4
Compare
@vnen made a great point on the issue:
So, I've switched to generating code per his suggestion, which puts everything on the This makes the code less readable, but as generated code, I don't think that really matters.
I've also applied a similar change in both these cases as well! (I strongly suspect that the compiler might be smart enough to inline the |
I finally got around to doing some benchmarking! My test project has image modifying functions based on the ones from issue #1063 It runs the GDScript and GDExtension versions of each function 50 times, and then reports on the total, average and median times of each function call. It takes the readings in microseconds, but converts them to milliseconds for the output. Here's what I got with current
And here's with the PR:
That's a pretty huge improvement! We go from ~4.5x slower than GDScript (on this benchmark) to ~3x faster - I'm kinda blown away :-) Thanks to @hilloftheking for tracking this issue down! |
This updates the generated method code to match what @BastiaanOlij suggested in this comment.
Currently, even though the method bind pointer itself is being cached (by virtual of being a local
static
variable), theStringName
with the method name (which is only created as an intermediate value in order to get the method bind pointer) is still constructed every time the function is called.With the changes in this PR, it should only be constructed the first time.
While this does probably improve performance, it will need more benchmarking to see if it sufficiently solves issue #1063, or if only helps things a little bit.
Fixes #1063