This article introduces Godot’s multithreading model:
That suggests that Godot multi-threaded can run logic, physics updates and rendering in parallel.
Rendering
The “rendering/threads/thread_model” settings is described as “Thread model for rendering. Rendering on a thread can vastly improve performance, but synchornizing to the main thread can cause a bit more jitter”. This suggests that with this setting only rendering is ran in a separate thread.
“Multithreaded” is internally called “RENDER_SEPARATE_THREAD”. Looking at Godot 3.2.3 code, seems that what this does is to wrap the VisualServer calls in a VisualServerWrapMT class and create a thread to consume the rendering commands queue (instead of consuming them sequentially in the main loop). Note that the same class is used for Single-Safe mode, but a separate thread is not used to dispatch commands.
In my code,. “Single Unsafe” crashes, and I have appreciated slightly smoother visuals when using “Multithreaded”.
Physics
For physics 2D, Multithreaded setting “physics/2d/thread_model” applies to a PhysicsServer attribute called “using threads”. Its documentation says:
“Sets whether physics is run on the main thread or a separate one. Running the server on a thread increases performance, but restricts API access to only physics process. Warning: As of Godot 3.2, there are mixed reports about the use of a Multi-Threaded thread model for physics. Be sure to assess whether it does give you extra performance and no regressions when using it.”
The implementation internally wraps the PhysicsServer code with a Physics2DServerWrapMT class that can (optionally, in the case of “Multithreaded”) do some tasks in a separate thread.
In my current code, this mode seems to work for a short span. Causes modified physics behavior, and ends up crashing the game process after 10-20 seconds.
Finally…
I assume that none of the “Multithreaded” mode doesn’t work or apply to HTML5 builds on current Godot 3.2.x version.
Personally, I don’t think it’s safe to change this once you have started a project. Note, however, that you can change the rendering threading model (but not the physics model) for an already generated Godot project by using the command line switch:
May I ask what makes you say you don’t think it’s safe to change it once you’ve started a project?
dmaz | 2021-02-03 03:38
If you change this setting in mid-development, your existing physics may or may not work, but unless you have designed your code with this in mind you may introduce different behaviours and regressions that you didn’t test for in the first place, and the fact that in my code changing this makes it crash (which shows that multithreaded implementations do behave different). That said, my statement is too blunt… just test, and use it if you are comfortable with it.