Search Unity

High CPU usage even with VSync on

Discussion in 'Scripting' started by claytoncurmi, Dec 10, 2018.

  1. claytoncurmi

    claytoncurmi

    Joined:
    Jul 6, 2010
    Posts:
    168
    Hi all,

    I am noticing high CPU usage on standalone builds. I tried setting VSyncCount to 1 (limits frames to 60FPS). I also tried to cap the frames by setting VSyncCount to 0 (disabled) and Application.targetFrameCount to 60 FPS (also tried with lower FPS). However in both scenarios the CPU usage is still very high. Whilst profiling the app, there is nothing that suggests that is consuming too much CPU as it can be seen in the attached screenshot. Any ideas about this?

    I am using Unity 2017.2.0f3

    Screen Shot 2018-12-10 at 11.14.07.png Screen Shot 2018-12-10 at 11.19.41.png
     
    Last edited: Dec 10, 2018
  2. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    I might be wrong on this, but how is vSync suppose to boost cpu performance?

    the profiler shows about 60% usage from your scripts, pop open the first two tabs there to see what's going on.
    turn on deep profile for more info
     
  3. claytoncurmi

    claytoncurmi

    Joined:
    Jul 6, 2010
    Posts:
    168
    vSync is meant to sync the FPS with the monitor refresh rate (hence throttling the frame count). Another way of doing this is to disable the vSync and cap the frames by setting targetFrameRate. If this is not done, the game keeps on trying to achieve max frames hence hogging the CPU. The game should use much less than 100%.

    As for the 60% usage it amounts to 3.87ms which means around 250FPS (as it can be seen from the graph). To me it looks like the game is running smoothly but I can't understand why it is occupying all the CPU.
     
  4. claytoncurmi

    claytoncurmi

    Joined:
    Jul 6, 2010
    Posts:
    168
    Anyone can shed some light on this please?