touilleMan/godot-python

performance issue

onyxblade opened this issue · 2 comments

Hi @touilleMan !

There has been a benchmark repository(https://github.com/cart/godot3-bunnymark) for different language bindings. Since the python benchmark is missing I wrote one. The code is in onyxblade/godot3-bunnymark@9ad9897.

Thus I found that pythonscript can only support 150 bunnies at 60fps in my computer. This number for gdscript is 4937 and for my ruby binding is 300. I think this difference worth investigation.

By the way, would gdscript run in multi-threads? I encountered a problem that the editor resource previewer would spawn a thread to run script_init() which crashes ruby vm because the vm doesn't support calling from multiple threads. I workarounded this but I wonder will instance_call_method() be invoked in multiple threads? Is pluginscript designed to work in multi-threads or in single-thread?

Thanks!

Hi @CicholGricenchos

Right now Godot-Python is not stable enough to consider any performance optimization (for instance there is still complex memory leaks occuring), so a 2x performance isn't much of a concern (I would be more concerned with the x15 difference with GDScript that suggest the wrapper layer brings a lot of inefficiency...).

That said, have you tried to run the benchmark with the Pypy version of Godot-Python ?

By the way, would gdscript run in multi-threads?

I don't known much about Godot and multithreading. From what I understood Godot runs all logic code in a single thread (but as you experienced, initializing scripts can be done from other threads...)
PluginScript&GDnative are just proxy stuff they have no idea which thread is calling them.
Note that in Godot-Python case, we use CFFI which handles transparently the call-python-from-multiple-threads trickiness ;-)

Yep 2x doesn't matter but 15x is the case. They are at the same level comparing to GDScript...
I just tried pypy backend which yields a result of 550.