Random huge performance spikes in builds (2022.3.13f)

I’m having a problem in builds where every few seconds I get a giant spike in performance, going from a frame time of 3ms in the frame before, to >1000ms and then back down to 3ms. This is happening all of the time, even when just standing still. When looking in the profiler, each time the spike shows as coming from something completely random each time, even coming from things such as lighting when my project uses no unity lights and everything is on unlit shaders.

I was previously on Unity version 2022.2.11f and upgraded to the LTS version 2022.3.13f to see if this would solve the problem, but its still occurs. Deep profiler also shows nothing different, however the spikes do occur more frequently and consistently, although they still show as coming from something completely random every time.

Here are some screen grabs of the profiler attached to a dev build.


I really don’t know how to proceed here, these spikes are extremely annoying and noticeable in gameplay. Any help or advice on how to track down the cause would be appreciated.

Could be related to [this issue]( Android build project freezes after 5 minutes with playerloop in profiler at 60,000 ms page-4#post-9453287), so maybe 2022.3.14f1 fixes it?

Alternatively, there might be GC.Collect work going on on a different thread while main thread freezes in random places. Check Timeline view to determine if that might be it.

Since that version isn’t out I figured I’d try the 2023.2.0f1 release and the issue still occurs in that version, so unfortunately it looks like the issue isn’t connected to that one.

1 Like

Heres is the timeline view, could it be related to those Semaphore.WaitForSignals in the Enlighten worker threads?

9487390--1335013--Threads1.PNG 9487390--1335016--Threads2.PNG 9487390--1335019--Threads3.PNG

Okay, further testing and it looks like the spikes were being caused by having the realtime GI checkbox on in the lighting settings, unchecking that box removes those threads and things seem to be running a lot smoother now :slight_smile: No idea why that setting was enabled.

1 Like

The semaphores probably waited on the Worker threads sorting the Render Loop? That or they spawned a whole bunch of Native Jobs without Profiler Markers that stole the cores out from underneath all other threads. There should have definitely been more idle samples there, at least on Worker 1.

It’s available now in the Hub. :wink:

1 Like