Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question CPU usage in Build is way too high

Discussion in 'Editor & General Support' started by georgestpds, Nov 20, 2022.

  1. georgestpds

    georgestpds

    Joined:
    Jun 29, 2021
    Posts:
    6
    Hello,
    So I got this issue where my cpu usage increases drastically in the Build compared to Unity's Editor.
    I should say that there's not much going on in the scene and judging by the profiler my scripts don't take up much.


    As you can see from this little screenshots montage, in the Editor's game window I setup the same resolution I have in the Build and I activated VSync for both.
    CPU usage when I play in the Editor is around 10% whereas in the Build it's usually 60% up to 80%.


    And as you can see in this second screenshot (profiler of the Build), what seems to take up most resources is someting called TimeUpdate.WaitForLastPresentationAndUpdateTime and WaitForTargetFPS.
    I guess this is because of Vsync and it would do the same with targetFrameRate. But what does it cost CPU to "wait"? Or am I misunderstanding this?

    Can someone help me understand?


    Edit:
    This is the Profiler when I disable VSync. CPU usage is at 76% on average.
     
    Last edited: Nov 20, 2022
  2. georgestpds

    georgestpds

    Joined:
    Jun 29, 2021
    Posts:
    6
    Ok, so if anyone is interested:
    I read the profiler wrong. What was going on is that the CPU was waiting for the GPU (I guess that's what WaitOnSwapChain is about). Anyway, in my case it had something to do with Realtime GI and a line of code I had in Update() of my DayNightCycle script. So now that's taken care of everything's fine. My build only takes 8% of CPU.

    But still, what I don't get is how come, when I still had that intense line of code in Update(), in the Editor it never went passed 10% of CPU usage (compared to the 60-80% of the Build)?