Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | madgit | |
Old Version | Published before Godot 3 was released. |
Hi,
I’m using 3.0RC1 with Mono, trying out C# scripts. I have a simple project that’s making meshes from simple Minecraft-like block chunks. It runs at ~160fps with vsync off so that’s fine, however every second or so I get stutters lasting a few whole frames.
Looking at the perf monitor I get downward spikes every ~1s, and the list of functions on the left is almost empty during those down spikes, indicating to me that the engine isn’t “doing” my code or the game at all for those few frames. Usually you see the list of Physics Time, Script Functions etc but in one of those spikes that mostly disappears to be left with just Script Functions and under it, do_player_movement (simple GDScript reading keys) and _process, both of which take 0.000 time.
Perf monitor during “normal” running period:
Perf monitor during one of the laggy spikes
Is it possible I’m seeing C# garbage collection or something? Why would it keep triggering every ~1s? The only scripts I have are those that create chunks on startup, once-only, and during running there’s nothing happening except moving the camera around by key. No C# scripts running at all to cause GC. I’ve minimised the obvious object creation (I don’t have huge arrays of Block objects, just simple arrays of int block types per chunk) and I can’t think where else the spikes might be coming from.
Interestingly, if I change the chunk size from 16x16x16 to 32x32x32 (thus getting much bigger chunk meshes but fewer of them) and simultaneously reduce the “radius” around the player from 4 chunks to 2 (to maintain the same overall distance), the spikes are basically gone. Could it be something in the graphics pipeline that’s thrashing every ~1s? (32 size chunks give ~250 surface changes & draw calls, 16 size chunks give ~2000 surface changes & draw calls, according to the Monitor).
Could it be something to do with the debugging and it might all vanish if I were able to export (can’t do this with Mono yet) ?
Thoughts?