godot: Godot 4.0 is very slow to start on macOS compared to 3.x
Godot version
4.0.alpha10.official
System information
macOS 12.4 (Monterey), Vulkan, Intel Iris Pro 5200
Issue description
Latest release of Godot 4.0 (alpha 10) seems to be super slow on macOS 12.4 (Monterey), at least when tested on my MacBook Pro setup (meanwhile, Godot 3.4.4 works without any noticeable performance issues). Here are some benchmarks:
- time to start Godot (to open project list): 33 seconds
- time to open new project: 35 seconds
- time to start an empty 2D scene app: 33 seconds
On the other hand, editor itself is generally responsive when interacting with its UI (creating new nodes etc.).
Among important details, here are some errors that are raised during the 2D application start (empty scene):
E 0:00:00:0276 _debug_messenger_callback: - Message Id Number: 0 | Message Id Name:
VK_ERROR_INITIALIZATION_FAILED: Render pipeline compile failed (Error code 2):
Compiler encountered an internal error.
Objects - 1
Object[0] - VK_OBJECT_TYPE_PIPELINE, Handle 140389825172992
<C++ Source> drivers/vulkan/vulkan_context.cpp:159 @ _debug_messenger_callback()
E 0:00:00:0276 render_pipeline_create: vkCreateGraphicsPipelines failed with error -3 for shader 'ClusterRenderShaderRD:0'.
<C++ Error> Condition "err" is true. Returning: RID()
<C++ Source> drivers/vulkan/rendering_device_vulkan.cpp:6614 @ render_pipeline_create()
E 0:00:30:0395 _debug_messenger_callback: - Message Id Number: 0 | Message Id Name:
VK_ERROR_INITIALIZATION_FAILED: Render pipeline compile failed (Error code 2):
Compiler encountered an internal error.
Objects - 1
Object[0] - VK_OBJECT_TYPE_PIPELINE, Handle 140389832876544
<C++ Source> drivers/vulkan/vulkan_context.cpp:159 @ _debug_messenger_callback()
E 0:00:30:0395 render_pipeline_create: vkCreateGraphicsPipelines failed with error -3 for shader 'ClusterRenderShaderRD:0'.
<C++ Error> Condition "err" is true. Returning: RID()
<C++ Source> drivers/vulkan/rendering_device_vulkan.cpp:6614 @ render_pipeline_create()
Also, here’s the editor output after Godot start, for the record:
--- Debugging process started ---
Godot Engine v4.0.alpha10.official.4bbe7f0b9 - https://godotengine.org
Vulkan API 1.1.198 - Using Vulkan Device #0: Intel - Intel Iris Pro Graphics
Registered camera FaceTime HD Camera with id 1 position 0 at index 0
--- Debugging process stopped ---
It seems that Vulkan support is not an issue on my MacBook Pro. I’ve just installed Vulkan SDK 1.3.216.0 for macOS from LunarG website and their vkcube.app demo works without any issues (thanks to MoltenVK underneath, of course).
I can provide any additional information or testing if that would help.
System details
- laptop: MacBook Pro (Retina, 15-inch, Mid 2015)
- CPU: Intel Core i7-4870HQ 2.5 GHz (Haswell)
- OS: macOS Monterey 12.4 (build 21F79)
GPU details (from system_profiler)
Chipset Model: Intel Iris Pro
Type: GPU
Bus: Built-In
VRAM (Dynamic, Max): 1536 MB
Vendor: Intel
Device ID: 0x0d26
Revision ID: 0x0008
Metal Family: Supported, Metal GPUFamily macOS 1
And by the way, thank you all for Godot! 🎉 It’s absolutely amazing that a game engine like this is available out there.
Steps to reproduce
No extra steps are needed to reproduce the issue. It seems that any MacBook with a similar spec would be prone to this problem.
Minimal reproduction project
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 25 (16 by maintainers)
I ran benchmarks of all versions since Godot 3.0.1 up to 4.0.alpha10:
Specifications
OS: Fedora 36 CPU: Intel Core i7-6700K @ 4.4 GHz RAM: 2×16 GB DDR4-3000 (dual channel) GPU: NVIDIA GeForce GTX 1080 (NVIDIA 510.68.02) SSD: Samsung 850 EVO 1 TB
Using official Godot Linux x86_64 release binaries downloaded from TuxFamily. An average of 25 runs is performed.
Benchmark source and data files (CSV, JSON, Markdown) are available at: https://github.com/Calinou/godot-startup-times
Results
Cold project manager start + exit
editor_data/and project folder are removed before every run.Godot_v3.0.1-stableGodot_v3.0.2-stableGodot_v3.0.3-stableGodot_v3.0.4-stableGodot_v3.0.5-stableGodot_v3.0.6-stableGodot_v3.1-stableGodot_v3.1.1-stableGodot_v3.1.2-stableGodot_v3.2-stableGodot_v3.2.1-stableGodot_v3.2.2-stableGodot_v3.2.3-stableGodot_v3.3-stableGodot_v3.3.1-stableGodot_v3.3.2-stableGodot_v3.3.3-stableGodot_v3.3.4-stableGodot_v3.4-stableGodot_v3.4.1-stableGodot_v3.4.2-stableGodot_v3.4.3-stableGodot_v3.4.4-stableGodot_v3.5-beta1Godot_v3.5-beta2Godot_v3.5-beta3Godot_v3.5-beta4Godot_v3.5-beta5Godot_v3.5-rc1Godot_v3.5-rc2Godot_v3.5-rc3Godot_v3.5-rc4Godot_v4.0-dev.20210727Godot_v4.0-dev.20210811Godot_v4.0-dev.20210820Godot_v4.0-dev.20210916Godot_v4.0-dev.20210924Godot_v4.0-dev.20211004Godot_v4.0-dev.20211015Godot_v4.0-dev.20211027Godot_v4.0-dev.20211108Godot_v4.0-dev.20211117Godot_v4.0-dev.20211210Godot_v4.0-dev.20220105Godot_v4.0-dev.20220118Godot_v4.0-alpha1Godot_v4.0-alpha2Godot_v4.0-alpha3Godot_v4.0-alpha4Godot_v4.0-alpha5Godot_v4.0-alpha6Godot_v4.0-alpha7Godot_v4.0-alpha8Godot_v4.0-alpha9Godot_v4.0-alpha10Warm project manager start + exit
Godot_v3.0.1-stableGodot_v3.0.2-stableGodot_v3.0.3-stableGodot_v3.0.4-stableGodot_v3.0.5-stableGodot_v3.0.6-stableGodot_v3.1-stableGodot_v3.1.1-stableGodot_v3.1.2-stableGodot_v3.2-stableGodot_v3.2.1-stableGodot_v3.2.2-stableGodot_v3.2.3-stableGodot_v3.3-stableGodot_v3.3.1-stableGodot_v3.3.2-stableGodot_v3.3.3-stableGodot_v3.3.4-stableGodot_v3.4-stableGodot_v3.4.1-stableGodot_v3.4.2-stableGodot_v3.4.3-stableGodot_v3.4.4-stableGodot_v3.5-beta1Godot_v3.5-beta2Godot_v3.5-beta3Godot_v3.5-beta4Godot_v3.5-beta5Godot_v3.5-rc1Godot_v3.5-rc2Godot_v3.5-rc3Godot_v3.5-rc4Godot_v4.0-dev.20210727Godot_v4.0-dev.20210811Godot_v4.0-dev.20210820Godot_v4.0-dev.20210916Godot_v4.0-dev.20210924Godot_v4.0-dev.20211004Godot_v4.0-dev.20211015Godot_v4.0-dev.20211027Godot_v4.0-dev.20211108Godot_v4.0-dev.20211117Godot_v4.0-dev.20211210Godot_v4.0-dev.20220105Godot_v4.0-dev.20220118Godot_v4.0-alpha1Godot_v4.0-alpha2Godot_v4.0-alpha3Godot_v4.0-alpha4Godot_v4.0-alpha5Godot_v4.0-alpha6Godot_v4.0-alpha7Godot_v4.0-alpha8Godot_v4.0-alpha9Godot_v4.0-alpha10Cold editor start + exit
editor_data/and project folder are removed before every run.Godot_v3.0.1-stableGodot_v3.0.2-stableGodot_v3.0.3-stableGodot_v3.0.4-stableGodot_v3.0.5-stableGodot_v3.0.6-stableGodot_v3.1-stableGodot_v3.1.1-stableGodot_v3.1.2-stableGodot_v3.2-stableGodot_v3.2.1-stableGodot_v3.2.2-stableGodot_v3.2.3-stableGodot_v3.3-stableGodot_v3.3.1-stableGodot_v3.3.2-stableGodot_v3.3.3-stableGodot_v3.3.4-stableGodot_v3.4-stableGodot_v3.4.1-stableGodot_v3.4.2-stableGodot_v3.4.3-stableGodot_v3.4.4-stableGodot_v3.5-beta1Godot_v3.5-beta2Godot_v3.5-beta3Godot_v3.5-beta4Godot_v3.5-beta5Godot_v3.5-rc1Godot_v3.5-rc2Godot_v3.5-rc3Godot_v3.5-rc4Godot_v4.0-dev.20210727Godot_v4.0-dev.20210811Godot_v4.0-dev.20210820Godot_v4.0-dev.20210916Godot_v4.0-dev.20210924Godot_v4.0-dev.20211004Godot_v4.0-dev.20211015Godot_v4.0-dev.20211027Godot_v4.0-dev.20211108Godot_v4.0-dev.20211117Godot_v4.0-dev.20211210Godot_v4.0-dev.20220105Godot_v4.0-dev.20220118Godot_v4.0-alpha1Godot_v4.0-alpha2Godot_v4.0-alpha3Godot_v4.0-alpha4Godot_v4.0-alpha5Godot_v4.0-alpha6Godot_v4.0-alpha7Godot_v4.0-alpha8Godot_v4.0-alpha9Godot_v4.0-alpha10Warm editor start + exit
Godot_v3.0.1-stableGodot_v3.0.2-stableGodot_v3.0.3-stableGodot_v3.0.4-stableGodot_v3.0.5-stableGodot_v3.0.6-stableGodot_v3.1-stableGodot_v3.1.1-stableGodot_v3.1.2-stableGodot_v3.2-stableGodot_v3.2.1-stableGodot_v3.2.2-stableGodot_v3.2.3-stableGodot_v3.3-stableGodot_v3.3.1-stableGodot_v3.3.2-stableGodot_v3.3.3-stableGodot_v3.3.4-stableGodot_v3.4-stableGodot_v3.4.1-stableGodot_v3.4.2-stableGodot_v3.4.3-stableGodot_v3.4.4-stableGodot_v3.5-beta1Godot_v3.5-beta2Godot_v3.5-beta3Godot_v3.5-beta4Godot_v3.5-beta5Godot_v3.5-rc1Godot_v3.5-rc2Godot_v3.5-rc3Godot_v3.5-rc4Godot_v4.0-dev.20210727Godot_v4.0-dev.20210811Godot_v4.0-dev.20210820Godot_v4.0-dev.20210916Godot_v4.0-dev.20210924Godot_v4.0-dev.20211004Godot_v4.0-dev.20211015Godot_v4.0-dev.20211027Godot_v4.0-dev.20211108Godot_v4.0-dev.20211117Godot_v4.0-dev.20211210Godot_v4.0-dev.20220105Godot_v4.0-dev.20220118Godot_v4.0-alpha1Godot_v4.0-alpha2Godot_v4.0-alpha3Godot_v4.0-alpha4Godot_v4.0-alpha5Godot_v4.0-alpha6Godot_v4.0-alpha7Godot_v4.0-alpha8Godot_v4.0-alpha9Godot_v4.0-alpha10Conclusion
The main takeaway is that 4.0.alpha10 is much slower to startup and shutdown compared to 4.0.alpha9, especially in cold runs. This suggests that the shader cache has more work to do since more shader variants have to be compiled, presumably due to TAA. cc @JFonS
4.0.alpha6 also has a noticeable regression in startup/shutdown speed compared to 4.0.alpha5 (both cold and warm), but mainly in the project manager.
I have this problem as well and looked into it a bit. I don’t have a solution but my findings so far is that one call to vkCreateGraphicsPipelines (for the shader ClusterRenderShaderRD:0) takes 30s. What happens is that the separate MTLCompilerService process crashes, and the caller times out & continues after 10 seconds. (It does 3 retries however, hence a 30s total delay). So it doesn’t seem to be a shader cache performance issue per se like @Calinou investigated, but a bug, possibly in the MoltenVK/Metal backend.
As for why it’s crashing is a bit more unclear. The callstack of the crashed thread in MTLCompilerService is:
It seems to me like it encounters an error, but fails to properly report it and crashes instead.
reportUnsupportedFunctionReferenceErroris seems like the biggest hint to to the cause to me. I have not been able to attach to the process with a debugger to try to extract more info. (The process is a bit transient.)While compiling it also emits
[MTLCompiler] Error: undefined reference to `air_simd_is_helper_thread()'to the system log. This happens more times than for the failing call though so I’m not sure it’s related.I don’t know if there are any more Vulkan/Metal logs to check, but let me know if there’s some place I should have a peek.
This is already being tracked in https://github.com/godotengine/godot/issues/43351. In general, Vulkan is expected to be slower to initialize compared to OpenGL – it’s a more complex rendering backend.
You can use https://github.com/Calinou/godot-reflection for this purpose 🙂
I’ve tested it and can confirm it works on 4.0.beta3.
Ok so I did a bit of a deep dive on this one, and basically yes the Metal compiler crashes and
[MTLCompiler] Error: undefined reference toair_simd_is_helper_thread()` is the closest to a detailed error there is. Unfortunately this is in internal proprietary code and not much to work with so that’s a bit of a dead end.However, with a bit of testing I figured out that what actually triggers this error is the usage of
gl_HelperInvocationin cluster_render.glsl:https://github.com/godotengine/godot/blob/c660cc4adc7032c11f74dfce5fcb7b5a02f6d097/servers/rendering/renderer_rd/shaders/cluster_render.glsl#L164
In my case it’s taking the non-
USE_SUBGROUPSpath and removing those two conditionals (i.e. running theatomicOralways) fixes the compiler failure and Godot starts fast.I’m not sure making a pull request of that makes sense because those conditionals are obviously there for a reason, and I’m not well versed enough in the shaders to know what the best alternative is. (As I understand it they’re there to avoid doing unnecessary calculations when the shader is run in a helper mode that doesn’t actually output anything, so removing it likely doesn’t cause any errors but may have performance effects. If I read the docs correctly atomicOr doesn’t actually do anything when in a helper invocation though so possibly it’s just basically a free NOP anyway, but someone who actually knows what they’re talking about should chime in.)
As an extra reference, this specific code is actually discussed in a separate but related discussion about subgroups + helper invocations in a Khronos GLSL issue, mentioning @reduz : https://github.com/KhronosGroup/GLSL/issues/35
I’d be happy to test alternative fixes on this computer where it normally fails, just let me know.
@kdada This is an unrelated issue. Also, your project is using the Forward Mobile backend, which is more compatible with lower-end desktop GPUs (including old Macs and MoltenVK in general). On the other hand, the project manager always uses the Forward Plus backend, even on GPUs that don’t support it well.
The project manager should probably always use the Forward Mobile backend (or Compatibility on GPUs that don’t support Vulkan), as there is no point in using the Forward Plus backend for it to my knowledge.
Yes, unfortunately. It’s maybe possible something in the shader triggers the error and can be avoided by adjusting it somehow, but the error reports I currently have available aren’t that much to work with.
For me this is around 30 seconds usually on 4.0. Before on 3.3 it launched under a couple of seconds.
I’m on Windows and I get close to 10 seconds of boot time significantly slower than 3.x. Also the entire experience is very sluggish until I turn off multi window mode then is fine.