-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Uses StringName
in GDExtension perf critical instance creation & method/properties setter/getter
#67750
Uses StringName
in GDExtension perf critical instance creation & method/properties setter/getter
#67750
Conversation
I've said this in the past. I think all these methods should receive |
@neikeq good point, I'm convertion everything to |
50624cd
to
a4af43e
Compare
0755c32
to
9871bac
Compare
@neikeq I've updated the PR, now what we have: GDExtension C API uses
On top of that, this simplifies the implemention for GDExtension user (it's much simpler to pass an array of |
0ad7d4d
to
0a949a8
Compare
@bruvzg can I merge it then ? |
6174311
to
1e8756c
Compare
It looks like this affects #61968, right? |
@Bromeon exactly ! I didn't even know about this issue 😄 |
Maybe also will help with #68375 |
I feel this PR was kind of pointless. None of these functions are performance critical and since StringName construction still needs to hash the cstring, it would have allowed you to optimize this on the side of the language bind. Now this is probably a lot more complex to implement and a lot more inefficient unless you keep StringNames cached everywhere for everything you do. |
Even worse, if you want to keep a hashtable on the extension side to optimize, how are you going to use the StringName for this? |
Maybe one possibility could be to have a C function to get some uint64_t from the stringname you can use for hashing. |
I don't understand, can you explain these optimizations in more details? Some pseudo-code may help. |
@neikeq StringName contains a pointer to a string table, which is what makes it fast. If you use it from GDExtension directly its probably going to be slower because you have to call the function pointers to compare it. I wonder maybe each implementation can implement comparison operators just checking the memory (pointer). If this is the case it should be fine. Either case, if there is consensus on using StringName for these things from those implementing extensions, I won't oppose. I just feel it may not have been necessary. |
This is what I do from C#. StringName has a very simple layout, just a pointer. |
@neikeq I have no idea how easy is to expose this to different languages, but if extension implementers are fine doing this, then I don't see the problem with this PR. |
Godot-CPP twin PR: godotengine/godot-cpp#896
Function such as
gdnative_classdb_construct_object
would obsviously benefit from usingStringName
instead ofchar *
(it's the whole point ofStringName
after all !)Functions such as
gdnative_variant_get_ptr_builtin_method
also benefit in case it is called as part of the actual function call (e.g. in dynamic language or if the output ofgdnative_variant_get_ptr_builtin_method
is not cached)On the other hand, I've kept use of
char *
inclassdb_register_extension_*
,GDNativeExtensionClassGetVirtual
functions andGDNativePropertyInfo
/GDNativeMethodInfo
/GDNativeExtensionClassMethodInfo
structures.The reason is those are not performance critical:
classdb_register_extension_*
are called once when the extension is initializedGDNativeExtensionClassMethodInfo
is only used byclassdb_register_extension_*
GDNativeExtensionClassGetVirtual
is cached by classDBGDNativePropertyInfo
/GDNativeMethodInfo
are only used byClassDB::get_method_list
/ClassDB::get_property_list
which are called by stuff like editor a gdscript analyzer, so I guess this is not used at release. However we may want to convert it anyway to speed up gdscript analyzer (though I don't know this code at all so it's very possible this would bring no real performance).I can update the PR if you think it would be better for consistency to use
StringName
everywhere.