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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Optimization. Strange Peaks in Profiler in HDRP

Discussion in 'High Definition Render Pipeline' started by oeMuseum, Nov 7, 2022.

  1. oeMuseum

    oeMuseum

    Joined:
    Jul 19, 2021
    Posts:
    4
    Hi all,

    I am having strange peaks in profiler when running my project. Actually, it behaves differently when in editor and when built. But in any case I experience peaks in render and scripting.
    Here the Profiler when running in Editor ("Other" disabled on purpose)

    ppNinternal.PNG

    There are some peaks, they come rather irregularly, PlayerLoop at around 4/5 ms, then (on peak) around 15ms. Apart from the peaks, rendering and Scripts (the main culprits) reach 200fps.

    In Build with "Deep Profiling Support" it looks like this:
    ppNbuild.PNG

    The peaks are quite regular here, time consumed goes from around 20ms to around 700ms when peaking. When switching off "Deep Profiling Support" it again looks differently in profiler. Again peaks in Rendering and scripting, while VSync limits everything to around 16ms:

    ppNbuildNoDeeep.PNG


    I already tried a lot of optimization and also I switched off Objects before building:
    - Removed all of my Meshes but my 3 Animated Cars
    - in addition remove Day/Night cylce script
    - in addition remove Sky and fog volume
    - Remove the animated cars
    - Remove Main script and Day/Night cylce script
    - ...
    In any case I experience the same peaks.

    I would be happy for any ideas on how I could approach further...

    Thanks in advance & have a good day!
    oe
     
  2. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,196
    If you load that capture into Profile Analyser, switch to compare mode, right click on the chart and select "Order By Frame Time" and then draw up a selection in the upper chart that only contains the normal frame time range, and a selection in the lower chart, that only contains the peaks, that should give you a good starting point to analyze how these frames differ and what might be running in them that could cause this.
     
  3. oeMuseum

    oeMuseum

    Joined:
    Jul 19, 2021
    Posts:
    4
    Hi MartinTilo,

    thanks for helping! Nice Tool, still I do not really understand.
    Hope somebody can help me checking this, see below. The pictures show the same window, only the columns are moved, so that one can read the names of the processes.
    Is all the problem in ..ProfilingScope..ctor()? And if yes, would that mean that I actually do not have this problem, as soon as I stop using Development build and profiler?

    Sorry, those questions might sound silly to you, but it is still rather confusing for me...

    pAnalyzer1.PNG

    pAnalyzer2.PNG
     
  4. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,196
    Ah no, that's a bug in how the SRPs did ProfilingScopes via their own struct instead of using ProfilerMarker. For the latter, the constructor for the autoscope and begin/end calls would be ignored by the deep profiler, but not for the former. (This resulted in garbled profiler data as the begin and end calls of the ProfilingScopes would be interleafed profiler calls to the constructor and destructor calls to their autoscope) The bug should be fixed in the latest patch version on the major (year) Unity version you are on, so if you want to analyze this while Deep Profiling, you might want to upgrade to such a version. Alternatively, non-Deep Profiling might produce cleaner results, if with less detail.

    It does look like, overall, the biggest difference is in Rendering cost and also including the Rendering thread in the analysis might yield more details of what exactly it is.