Cache function pointers in global tables by Bromeon 路 Pull Request #387 路 godot-rust/gdext (original) (raw)

馃敟 Detailed article here: https://godot-rust.github.io/dev/ffi-optimizations-benchmarking


Instead of repeatedly loading method pointers from Godot for each FFI call (including all the expensive StringName construction), this PR preloads all function pointers at startup. Includes:

This not only improves performance (#11), but also reveals any incompatibilitities or missing methods in Godot immediately. For example, this helped reveal godotengine/godot#80852. On the downside, a single method can prevent gdext from loading (even if that method is not used); however this likely points to an incompatibility that needs to be addressed anyway.

Other changes in this PR include:

Still missing:

After everything's been done, the codegen crate needs a heavy refactoring. Contributors planning to change that area are recommended to wait a bit.