Search Unity

Question Random huge performance spikes in builds (2022.3.13f)

Discussion in 'Editor & General Support' started by JWgames, Nov 22, 2023.

  1. JWgames

    JWgames

    Joined:
    Jun 29, 2015
    Posts:
    7
    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.

    Spike2.PNG
    Spike3.PNG

    Spike1.PNG

    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.
     
  2. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,452
    Could be related to this issue, so maybe 2022.3.14f1 fixes it?
     
  3. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,452
    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.
     
  4. JWgames

    JWgames

    Joined:
    Jun 29, 2015
    Posts:
    7
    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.
     
    MartinTilo likes this.
  5. JWgames

    JWgames

    Joined:
    Jun 29, 2015
    Posts:
    7
    Heres is the timeline view, could it be related to those Semaphore.WaitForSignals in the Enlighten worker threads?

    Threads1.PNG Threads2.PNG Threads3.PNG
     
  6. JWgames

    JWgames

    Joined:
    Jun 29, 2015
    Posts:
    7
    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 :) No idea why that setting was enabled.
     
    MartinTilo likes this.
  7. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,452
    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.
     
  8. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,892
    It's available now in the Hub. ;)
     
    MartinTilo likes this.