Search Unity

Low hardware usage but high computation time

Discussion in 'Editor & General Support' started by Yveo, Jun 17, 2021.

  1. Yveo

    Yveo

    Joined:
    Apr 21, 2016
    Posts:
    3
    I've got a problem, that I just can't quite wrap my head around.

    My Threads have a high computation time (please ignore the terrible optimization regarding tris)


    But at the same time my hardware is not being utilized fully, all cores of my CPU are being used about equally, so that doesn't seem to be the problem.

    .

    Although the CPU seems to be the bottleneck, I can get Unity to utilize the potential of my GPU close to 100% by setting the resolution to 8k, so it doesn't seem to be an issue of my PC not allowing unity access to the full ressources.

    Here's a snippet of my profiler:



    I'm using Unity version 2021.1.11f1 with HDRP version 11.

    This might just be an error in my head, and I'm lacking a basic understanding of why it is not possible to use more computation power to receive a lower thread computation time and in the end higher FPS, and if that's the case I'd appreciate it, if somebody would take the time to explain it to me.

    Thanks for your help!
     

    Attached Files:

    el_kontexo likes this.
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,911
    Notice that much of the time in the profiler is things like
    Semaphore.WaitForSignal
    , and it's also mostly under DoRenderLoop. This indicates that the main thread is waiting for some other thread to do something before proceeding. Usually this means things like waiting for Jobs to finish, or waiting for the GPU to finish rendering, or other such things. So these will affect your framerate without directly using your CPU on the main thread.
     
    el_kontexo and Yveo like this.
  3. Yveo

    Yveo

    Joined:
    Apr 21, 2016
    Posts:
    3
    Thanks for your reply!
    Strangely enough most of the Jobs are also on Idle for most of the render time, and I can't seem to be able to find out what exactly is causing the render loop to wait.


    Reducing the Tri count obviously increases FPS (but not by as much as I'd expect with my hardware), but Semaphore.WaitForSignal still remains in about the same quantity.
    I'd appreciate tips, on finding out what exactly is causing a thread to wait, I never seemed to be able to put my finger on that and it always was a bit more of a "poking around, until something works" for me.
     
  4. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
    Not sure where you saw any WaitForSignal under the render loop as the main thread is cut off in that screenshot... Anyways, you're clearly CPU bound with most of that time spend in rendering, both on the main thread and render thread, with a tiny bit of that jobbified across all threads. By and large, anything but the main and render thread, and therefore those cores, are pretty much un-used. That's what the percentage in the task manager is based on. There should be a per-core utilization visualization in the task manager too, that should show one core basically maxed out.

    Also note that a good chunk of time is spend on computations for the Editor (see the EditorLoop sample in there). You could switch the target to the Editor to see what exactly is eating your time here but if you want to see how to improve performance for your end-users, you should probably be profiling a build on your target platform instead.

    And then, you'll likely want to look into CPU rendering performance improvement guides to prepare the work for the GPU faster.
     
    el_kontexo and Yveo like this.
  5. Yveo

    Yveo

    Joined:
    Apr 21, 2016
    Posts:
    3
    Yeah you're right - I just noticed that Unity is indeed only using 4 of my 16 cores.
    Is there a way for the HDRP Rendering to make use of all/more of them?

    I'll definitely look more into CPU rendering performance improvements, but I'm having a hard time finding good guides/ressources for that specifically. I am also a bit restricted by the constraints of the game I currently am working on - in short the troublesome parts are a procedurally generated world with many Game Objects that need to be seperate so that they individually are collectible, as well as procedurally changing time & weather.

    Thanks for your help!