Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Switch from 2019 to 2021 cause high cpu usage and fps drop

Discussion in '2021.2 Beta' started by nuciforanicolas, Aug 8, 2021.

  1. nuciforanicolas

    nuciforanicolas

    Joined:
    Nov 29, 2018
    Posts:
    15
    Morning,

    I switched my URP project from unity 2019.4.5f1 to 2021.1.16f1.

    On 2019, cpu usage was about 2.2ms and 400-500 fps. When i switched to 2021, cpu goes up to 4-9 ms and fps drops to 70-120.

    How can i fix it?

    • 2019:
    stats 2019.jpg
    profile 2019.jpg

    • 2021:
    profile 2021.jpg stats 2021.jpg

    Thank you.
     
  2. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    Can't help much without the profiler. Use it and check out what's causing the large difference in PlayerLoop time, and you'll find the cause.
     
  3. Rastapastor

    Rastapastor

    Joined:
    Jan 12, 2013
    Posts:
    589
    At first glance is not the same scene considering the statistik window
     
  4. nuciforanicolas

    nuciforanicolas

    Joined:
    Nov 29, 2018
    Posts:
    15
    Thank you for answering!

    This is what i got from profiler looking for a frame with high cpu time usage.

    • 2019:
    2019.jpg
    • 2021
    2021.jpg


    I can assure you that it's the same scene. I noticed that vertex in 2021 are very high (18000) compared to 2019 (5000). But i just switch from 2019 to 2021, I didn't modified anything.

    Thank you!
     
  5. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    Seems like the editor overhead. Make a build and check the FPS using MSI afterburner (or any FPS software, or performance gui asset), or make it a dev build and auto connect the profiler.

    Profiling the editor can be misleading as the editor tends to have a big overhead.
     
  6. nuciforanicolas

    nuciforanicolas

    Joined:
    Nov 29, 2018
    Posts:
    15
    Ok, i will try. The tris and verts difference between 2019 and 2021 can be related to high cpu and low fps?
     
  7. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    I doubt it, the difference is negligible
     
  8. nuciforanicolas

    nuciforanicolas

    Joined:
    Nov 29, 2018
    Posts:
    15
    This is what i got.

    • 2019
    2019.jpg

    • 2021
    2021.jpg
     
  9. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    Click on Profile Modules and tick the GPU.
    If it's not showing anything in the build, then switch to the editor and profile again with the GPU module enabled. It's in the profiler, top left, above Rendering. Get to the same scene/frustum view and profile the GPU. How long does the GPU take?

    Profiling the GPU in the build will not work if you have Graphic Jobs enabled in the Player settings. Graphic jobs don't run in the editor though, only in build.

    Also, what are your computer specs?

    It seems like you might be GPU bottlenecked.
     
  10. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    Also make sure VSync is Off.
     
  11. nuciforanicolas

    nuciforanicolas

    Joined:
    Nov 29, 2018
    Posts:
    15
    The build is for android. So, if you are right about GPU bottleneck, it is related to my PC and to the editor only, right?
     
  12. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    If you ran the build in android, then it's the phone's specs that matter, not your PC.
    But if you're running the game in the editor using your PC, then your PC specs will be the ones that matter.

    Profiling the GPU in the editor doesn't have as much overhead as the CPU, so it's more accurate (not as perfect as a build though). The ideal thing to do is Disable Graphic Jobs, make a new build, run it on android, and profile the GPU & CPU using auto connect profile.


    https://docs.unity3d.com/Manual/ProfilerGPU.html
    Not sure GPU profiling works on an android though. If not, then do it on your PC, not as helpful but it's something.
    Looks like OpenGL for android works for GPU profiling.

    I'm surprised the GPU might be a bottlenecked considering what I'm seeing, it seems to be very simple.
     
  13. nuciforanicolas

    nuciforanicolas

    Joined:
    Nov 29, 2018
    Posts:
    15
    I can't profile GPU on android because vulkan is not supported.

    This is what i got on pc:

    • 2019
    cpu 2019.jpg
    gpu 2019.jpg

    • 2021
    cpu 2021.jpg
    gpu 2021.jpg
     
  14. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    can you expand TimeUpdate.WaitForLastPressentationAndUpdateTime
     
  15. nuciforanicolas

    nuciforanicolas

    Joined:
    Nov 29, 2018
    Posts:
    15
    That was Wait fo Target FPS. I used it to have 60fps on android. Without it, most cpu usage is from render pipeline manager (1-2ms), rendering main camera Same for gpu usage (about 6ms).
     

    Attached Files:

  16. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    Maybe that's why? Cause based on your recent profile pictures, looks like they're performing around the same.
     
  17. nuciforanicolas

    nuciforanicolas

    Joined:
    Nov 29, 2018
    Posts:
    15
    I made a windows build. The frame rate reach 300fps. The cpu usage is about 5ms and the most cpu usage is from dxgi wait on swap chain.

    Maybe is just a problem with the new version of unity? Because settings are the same, the game (for now) is simple on models and this is my laptop spec:

    cpu: i5 7300hq
    gpu: gtx 1500 ti
    ram: 8gb
     
    MousePods likes this.
  18. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    Not sure, but when you're talking about such high FPS numbers, the difference is actually very small.
    When you say 500 FPS vs 300 FPS, you feel it's large but that's a bit misleading. The actual difference is 1ms.

    500 FPS is 3ms, while 300 FPS is 2ms. 1ms difference is extremely small.
    I don't use URP currently or i would've tested it myself.
     
  19. nuciforanicolas

    nuciforanicolas

    Joined:
    Nov 29, 2018
    Posts:
    15
    So, i should ignore it for now
     
  20. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    Yeah, is it causing you any performance issues on your target platform? Are you hitting your target frame rate on the devices you want to support? if both are good, your fine.

    When you have time, read and learn the profiler. It's very helpful, once you know it well, any performance issue is easily identifiable.

    You might want to stick with LTS versions for better stability by the way. Unless you really need a feature only available in newer versions.
     
    nuciforanicolas likes this.
  21. nuciforanicolas

    nuciforanicolas

    Joined:
    Nov 29, 2018
    Posts:
    15
    I switched to 2020 but same situation. When installing the apk on my phone, it takes about 10 seconds to start (with 2019 was istant)
     
  22. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,448
    Did you try profiling it? Auto-Connect Profiler can help to profile startup times. If you don't see the first frame due to exceeding the buffer size, you can start the app via ADB and pass
    -profiler-maxusedmemory 67108864 (64MB, default 16MB).
    Also, the -profiler-enabled option to start profiling immediately can be used even without Auto-Connect option and e.g.
    -profiler-log-file <Path/To/Log/File.raw> and -profiler-capture-frame-count <NumberOfFrames>. combines with deep profiling support and -deepprofiling as well.
    (More details)

    That all said, 10s sounds like Auto Connect Profiler is already on and looking for an editor that wants to profile the startup, but can't find it and then times out after 10s