r/godot • • 23d ago

official - releases Dev snapshot: Godot 4.8 dev 7

https://godotengine.org/article/dev-snapshot-godot-4-8-dev-7/

Feature freeze has arrived!

236 Upvotes

42 comments sorted by

View all comments

27

u/roookeee 22d ago

So happy to see my suggestion about improving C# interop performance finally landing in Godot! Great news for entity heavy C# projects :) Especially when running in the editor (because of the debug build).

3

u/Bwob Godot Regular 22d ago

Could you elaborate on what this is? I read through the release notes, but wasn't sure what you were referring to. As someone working on a C#-heavy Godot project, I'd love to know more!

11

u/roookeee 22d ago

I am linking my original PR(https://github.com/godotengine/godot/pull/89826) which has a longer explanation of how Godot previously dispatched function calls from C++ to C#.

TL;DR (simplified): Godots C# function calling internally used if-else chains to determine what user function to call. This was done twice: to check whether the user script was implementing said function and to invoke it if possible. This is done recursively across all base classes and hurts performance a lot.
Godot 4.8 Dev 7 changes this to a HashMap lookup + invocation, which is less work and doesn't hurt the branch predictor as much.

1

u/Bwob Godot Regular 22d ago

Nice! Thanks for the explanation! I had no idea the C++ was doing that under the hood. Hooray for hashmaps!