Search Unity

Great difference CPU usage between standalone and editor

Discussion in 'Editor & General Support' started by Barritico, Jul 1, 2019.

  1. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    181
    I have a project that I have been designing since the first Unity versions of 2017. Now I have version 2019.1.5f1 installed

    The fact is that this night I make a build, I have tested it on 3 computers with different features and the CPU usage did not exceed 30%

    Today I opened the project and I removed some 20 trees that occupied a road. Nothing important. I have tried in the editor and the CPU went as usual.

    When doing the build and running the game, the CPU does not drop by 80%. In none of the three computers.

    I do not know what can happen. The story is just as I tell it.

    Any ideas?

    Thank you.
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    5,995
    You haven't given much info to go on. My first guess would be your FPS is higher now than it previously was. You should profile your previous build vs your current build.
     
    Barritico likes this.
  3. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    181

    Thanks for your reply.

    It is very difficult to work like that. The CPU usage is not increased by 30% in the editor. However, when I make a build (PC) and execute it, it shoots at 55-65%

    It is also impossible to obtain conclusions with the profiler.

    I have tested on three computers with different configurations.

    - i7 4790 - GTX 1060 - 16 GB RAM
    - i5 8400 - RADEON R9 - 8GB RAM
    - i5 6700 - GEFORCE GTX960 M - 8GB RAM (portable)

    With all drivers updated.

    And in all the same thing happens. With higher or lower incidence (+ - 5%) the CPU usage is triggered.

    But I do not know what else to investigate. And taking a product like that to the market is a guaranteed failure.
     
  4. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    4,110
    Do you have V-Sync turned off?

    If @Joe-Censored is guessing correctly, your FPS has shot through the roof. This would happen if your game used to have to wait much longer on the GPU than it currently does.

    There's a longer explanation, but the short one is that with Unity runs Update as often as it can. It will happily eat your entire CPU by calling Update 1000s of times per second. You really don't need it to run any more than once per frame.

    VSync caps your FPS to match your screen's framerate. It's not meant to limit runaway cpu use, but that's one of the fortunate side effects it has.
     
    Joe-Censored likes this.
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    5,995
  6. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    5,995
    Playing the game in the editor is really just for convenience purposes for faster iteration. Performance within the editor is not indicative of performance within a build. There are several reasons for this, one is all the extra debugging functionality employed while running in the editor, another is the lack of optimization compared to what goes into a release build, another is a lot of things that are run multithreaded in a build are run on the main thread in the editor.

    You should almost entirely ignore the game's performance when run in the editor. Playing the game within the editor is just not for that kind of testing.

    Ummm... false. If you had done what I suggested, you'd be able to see what exactly the CPU is spending its time on, even down to the specific script function, and what the FPS difference is between your previous build and your current build.

    Higher FPS = more Update loops called per second = more CPU used
    If that is your problem, you can cap the frame rate if you want. Otherwise, in a Standalone build Unity by default will run at the fastest frame rate the hardware can handle. Again USE THE PROFILER TO SEE IF THIS IS THE ISSUE.

    Well, now you know the issue isn't hardware related.

    You've already been told what to investigate. I also fail to see why 55%-65% CPU usage in a video game guarantees market failure. That's just silly.
     
  7. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    181

    Thanks for your time and explanations.

    I do not share this

    "You've already been told what to investigate. I also fail to see why 55%-65% CPU usage in a video game guarantees market failure. That's just silly"

    but I will not say it is just silly.
     
    Last edited: Jul 5, 2019
  8. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    181
    Thank you very much for your explanation and your time.
    I will put it into practice immediately.

    Best regards