Search Unity

Help With Performance "Humps" Caused by Intermittent Poor Rendering Performance

Discussion in 'Universal Render Pipeline' started by killerfrogy, Nov 4, 2021.

  1. killerfrogy

    killerfrogy

    Joined:
    Sep 17, 2013
    Posts:
    12
    Hello reader, I hope your day is going well :) As the title suggests I'm after help regarding some performance "humps". I use the word "hump" here because it feels like "spike" is the wrong word. You see, when I am play testing my game it suffers from frame rate drops that last for around 100 frames. This is what it looks like in the "CPU Usage" section of the (standalone) profiler:
    upload_2021-11-4_14-50-21.png t
    This issue has been plaguing me for a while and so I'm really keen to get to the bottom of it. I'll provide some more detail. The game is a 2d procedurally generated game, here's a screenshot for context:
    upload_2021-11-4_14-54-26.png
    I'm sure a few of you reading may have read "procedurally generated" and then assumed that some content being generated somewhere is the cause. However I have mostly ruled this out by adding my own profiler stats to track 'chunks loaded', 'tiles built, 'mobs spawned', 'lighting updated', etc, for all the major sources of computation. These are all reading as zero during the hump and to make extra sure, when I'm attempting to debug this issue I just idle the character in one spot and wait. The humps just come and go with no changes to the scene occurring that I can see.

    Now, why I think this is due to rendering/graphics performance is due to the hierarchy section of the profiler. During this hump period "PostLateUpdate.FinishFrameRendering" goes from averaging 3.5ms per frame to an average of around 16ms per frame. The specific culprit seems to be lnl_RenderCameraStack, with the various cameras all exhibiting a performance hit equally.

    I have spent a long time trying to resolve this issue and I have recently discovered something, however I am not sure how relevant it is. Whenever this issue occurs I also get spikes for "vertex buffer upload in frame" and "index buffer upload in frame" The former goes from around 60kb during the good performance period to 400kb during the bad period. The upload doubles from 15kb to 30kb. Here's what this looks like in the profiler in relation to the hump:
    upload_2021-11-4_15-5-0.png
    The red line is vertex buffer upload and the orange line is index buffer upload. Now at this stage I am unsure if this is a symptom of the issue or the cause, also interestingly the spikes never seem to quite line up with the hump.

    I have very likely not provided all of the details each of you may be after in order to help me, so please feel free to ask for these details and I will strive to supply them.

    Thank you for any help you may be able to provide, I've been chasing this issue for months and really need it.
     
  2. killerfrogy

    killerfrogy

    Joined:
    Sep 17, 2013
    Posts:
    12
    Oh, I'm using unity 2021.2.0 at the moment, but the issue was present in 2021.1. I'm using the URP along with plenty of shaders made using shadergraph. There are around 8 cameras in the scene. From what I can tell though, none of this runs particularly poorly during the hump, just an all round general drop in rendering performance. I'm running the game on an acer predator an515-52. Specs are 32gb of ram, gtx1060, i7 processor with 6 cores/12 virtual cores. Outside of the hump I can get as much as 200fps, during, it drops as low as 30fps.
     
  3. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,109
    Hi

    Do you have the same issue on other machines?
    It really looks like for me that you have another process running and eating performance of you PC time after time :)

    May be it is your anti-malware?
     
  4. killerfrogy

    killerfrogy

    Joined:
    Sep 17, 2013
    Posts:
    12
    That is a good train of reasoning, I have actually thought of this too but don't have a great way to test it easily as I am without another adequate machine to test on. Do you know if I could boot in safe mode but also allow my game to execute? that would be a good way to test this I think. The other reason I thought this may not be the cause is because when I play other games on my laptop I don't seem to encounter this. But that is anecdotal evidence and it would make sense that I extra notice this happening with my own game as I am so critical of all aspects of it when I play, including performance.
     
  5. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,109
    Actually dont know how to test, may be the only way is sit and look on your task manager while this happens in profiler :)

    Main reason why I think it is some external force is this:
    upload_2021-11-4_15-12-6.png

    You have more time in every aspect of frame. It is looks like another program took CPU time or you CPU just try to go a sleep :) and lower operation frequency.

    I work on Gaming Laptop and can create this behavior for myself by just unplug power cord. Then entire Laptop goes from 4Ghz to something like 1.5Ghz and my performance drops to level of low end mobile phone in editor :)

    Everything becomes way slower in profiler like on this image.
    If you have any way to reduce frequency of CPU/GPU then it can help I think :)