Search Unity

Feedback (Case 1211383) Some Editor Overhead in Playmode debunked

Discussion in '2019.3 Beta' started by Peter77, Jan 14, 2020.

  1. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    4,416
    I believe I made an interesting observation that hopefully helps to solve some of the existing editor overhead performance problems during play mode, which often cause my game to become very laggy and sometimes almost unplayable in the editor (eg this).

    I observed Unity adds a significant processing cost while holding down keys.
    Some key combinations cause the editor performance to drop significantly.
    In a first person shooter you navigate through the world via WASD-keys and SHIFT-key to run, which causes the editor to drop performance significantly, just because of holding these keys.

    The performance drop depends on the window the mouse pointer is located.
    The performance drop is significantly worse while the mouse is over the Hierarchy window than the Game window for example. When testing/playing in the editor, the mouse very often ends up or moves over the hierarchy window.

    1.png

    2.png

    3.png

    I've recorded a rather lengthy video where I go over these findings, which hopefully helps you to solve these performance drop issues.

    Please note that in this test there is no actual game running. It's an empty project. In a real project, you actually have your 30ms (or whatever) spend on the game. If another 30ms kicks in just for editor keystroke processing, this gets unplayable quickly.

    Reproduce
    • Open attached project
    • Open SampleScene
    • Open from main menu "Window > Analysis > Profiler"
    • Switch Profiler to Editor mode and start recording
    • Press Play
    • Hold down "A" key and observe performance in Profiler
    • Hold down "Shift+A" key and observe performance in Profiler
    • Hold down "Shift+A" key while moving the mouse over the Hierarchy and observe performance in Profiler

    Actual
    Holding down keys cause a huge performance drop.

    Expected
    No performance drop.
     
    Last edited: Jan 14, 2020
  2. DoctorShinobi

    DoctorShinobi

    Joined:
    Oct 5, 2012
    Posts:
    115
    When I was a child my grandfather used to tell me stories about Peter77. He said the common folk called him "QA Jesus" back in the day and that he was feared by all programmers in the west.

    Congrats on yet another detailed performance bug report
     
  3. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    4,416
    QA Jesus, LOL!

    I guess inside Unity Technologies it's more likely they refer to me as "oh no, not him again" ;), even though I have no ill intentions. Really!

    Just kidding, I know Unity staff appreciate my reports, they told me on various occasions.
     
    Last edited: Jan 14, 2020
  4. rastlin

    rastlin

    Joined:
    Jun 5, 2017
    Posts:
    123
    I imagine, at UT, people meeting in kitchen for coffee or something and chatting:

    Nice job Peter!
     
    spryx, Griz, karl_jones and 2 others like this.
  5. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    4,416
    I like the dramatic music idea, that's hilarious!
     
  6. DoctorShinobi

    DoctorShinobi

    Joined:
    Oct 5, 2012
    Posts:
    115
    Dev's parents:
     
    Bordeaux_Fox likes this.
  7. KokkuHub

    KokkuHub

    Joined:
    Feb 15, 2018
    Posts:
    66
    You're not a good QA until developers flinch and recoil when they hear your name.
     
    Peter77 likes this.
  8. Metron

    Metron

    Joined:
    Aug 24, 2009
    Posts:
    999
    Is this also happening when you hover the inspector window? It might be possible that the performance drop induced by moving the mouse button is the result of highlighting an entry in the hierarchy...
     
    Peter77 likes this.
  9. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    4,416
    Holy Moly! They just turned me into QA Jesus for real...
    upload_2020-1-14_18-1-24.png

    Whoever this was: Touché :)
     
  10. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    4,416
    The performance impact while holding A, while the mouse pointer is over an empty Inspector window, is the same as when the mouse is over the Game View.

    If there is an object assigned to the Inspector, it shows the same "base cost" for the additional key processing.

    In addition to that, whenever the mouse moves over an UI Inspector element that has a hover state, it triggers a repaint, which is expensive. Perhaps that's also the problem with the Hierarchy.
     
  11. benjamminlaner

    benjamminlaner

    Joined:
    Apr 5, 2015
    Posts:
    16
    This is possibly the greatest forum thread of all time.
     
    JonSWEDEN and Peter77 like this.
  12. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    4,416
  13. jdtec

    jdtec

    Joined:
    Oct 25, 2017
    Posts:
    103
    Amazing :)

    It's the least you deserve for submitting all these reports though...
     
    Peter77 likes this.
  14. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    107
    So everytime I call the Unity Input class, I get these spikes in my game? Is it just in the editor playmode or also in build?
     
  15. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    4,416
    No, that shouldn't be the case, or it's at least not what I observed.

    The spikes seem to be related to the editor only.
    I have not seen this in a build.
    The Input API does not seem to play a role in this.
     
  16. tspk91

    tspk91

    Joined:
    Nov 19, 2014
    Posts:
    106
    Woah, this is actually happening. In our project it turns 55 fps to 30!

    The perf impact really varies from key to key, taking as a reference Control and Alt: Enter causes 2x the spike, and Shift actually doesn't cause any.

    Tthe editor still has huge overhead in play mode, even when no input is present and with the GPU almost idling. It even has a "heartbeat". Gonna have to post a ticket.
    editoroverheadreadout.png
     
    Last edited: Jan 21, 2020 at 12:26 PM
  17. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,626
    Hi, we are looking into these issues.
    The heartbeat is the profiler window, it only updates every 5 frames for performance reasons.
    Part of the issue in 2019.3 is the profiler window itself, if you hold down A it then shows the timeline view which has a higher perf cost. We are looking into changing this default Key.
    We are also developing an Out Of Process Profiler which will let you capture without the overhead of the profiler itself in the results.

    If you want to compare between versions then the Profile Analyzer is a very good tool to do this https://blogs.unity3d.com/2019/05/13/introducing-the-profile-analyzer/
     
    tspk91 and Peter77 like this.
  18. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    288
    That sounds very nice!
     
  19. tspk91

    tspk91

    Joined:
    Nov 19, 2014
    Posts:
    106
    In my computer the interval seems to be 67 frames in an empty scene.

    Testing an empty scene just with a FPS counter (not even a camera), EditorLoop still eats 7.5 ms when the only open window is Game. I haven't noticed the profiler making much of a difference, does it always run in the background?

    editoroverheadempty.png

    PS: this is with 2019.3.0f3.
     
    Last edited: Jan 21, 2020 at 12:29 PM
  20. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,626
    It could be something else. Just look in the profiler and it will show you what is happening in the spike.

    How much did it use for you in previous unity versions?

    No, it only runs in the background if its enabled via the editor or a script.
     
  21. tspk91

    tspk91

    Joined:
    Nov 19, 2014
    Posts:
    106
    Just more of EditorLoop, 30 ms.

    I'll test later at home with 2018.3.
     
  22. tspk91

    tspk91

    Joined:
    Nov 19, 2014
    Posts:
    106
    Tested it with 2018.3.14f1, there is still EditorLoop there (what does it do that is updated every frame without any input?), but it is only 2.7 ms instead of ~8. It is an inconvenience when testing VR in the editor.

    upload_2020-1-22_3-21-53.png
     
unityunity