Skip to content

C# running in Godot is about 5x slower than running it from a Console app #96435

@dotlogix

Description

@dotlogix

Tested versions

  • Reproducible in: v4.4.dev1.mono.official [28a72fa].

System information

Windows 11, Godot 4.4-dev, Vulkan, Jetbrains Rider, .Net 9

Issue description

In one of my tests I tried to run some benchmarks because I couldn't find any issues in my code anymore related to performance and profiling did not lead to any significant results.

In that test I executed the exact same logic from a Console app to use it with Benchmark.Net and noticed that the code running in the Console is about 5x as fast than running it in Godot.

In my actual environment these calls are running in a separate Thread pool so it shouldn't be related to Godot itself but to the .Net runtime used by Godot

Expected:
Performance of C# code running in Godot is about the same as running it from a Console app

Actual:
Performance of C# code running in Godot is ~5x slower than running it from a Console app

Steps to reproduce

Create a C# project and create a CPU heavy task.
Run this in a tight loop ~10k times

Execute the same logic in a Console app and compare the results

Minimal reproduction project (MRP)

performancetest.zip

This is a small part of my VoxelEngine I am currently writing in pure C#, it contains quite a bit of Code but for very simple tasks I couldn't produce a huge amount of difference ~1ms per iteration.

Pls note that this code runs before anything renders at all so I would assume it should perform the same.
But this project shows a HUGE difference.
The results are:
Console: Took 23s
Godot: Took 1m 30s

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions