Search Unity

Entities 0.2 and 0.3 Performance issue for entering play mode due to Asset Pipeline v2 dependency

Discussion in 'Entity Component System' started by pocketpair, Dec 7, 2019.

  1. pocketpair

    pocketpair

    Joined:
    Jul 7, 2015
    Posts:
    72
    At least on editor, both of entities 2.0 and 3.0 have a performance issue when entering play mode.
    On entities 2.0 or 3.0, when "Project View" is shown, the performance is more worse.

    These profiling is on unity 2019.3.0f1
    New project with specific entities version. (It also reproduced on entities 2.0.)
    I disabled burst compile for comparison.

    FYI, in our main project, the time of entering play mode is more than twice. (around 10 seconds => around 40 seconds.) It really affects our development.

    Is there anyone who feels something performance issues?
    I wonder it would be related with live link.

    [entities 0.1.1 without project view]
    End Reload Assembly: 1252.69 ms
    ProcessInitializeOnLoadAttributes: 64.10 ms
    UpdateScene: 253.79 ms

    [entities 0.1.1 with project view]
    End Reload Assembly: 1420.86 ms
    ProcessInitializeOnLoadAttributes: 62.16 ms
    UpdateScene: 253.43 ms

    [entities 0.3.0 without project view]
    End Reload Assembly: 2649.87 ms
    ProcessInitializeOnLoadAttributes: 366.20 ms
    UpdateScene: 343.27 ms

    [entities 0.3.0 with project view]
    End Reload Assembly: 2574.92 ms
    ProcessInitializeOnLoadAttributes: 387.89 ms
    UpdateScene: 1255.29 ms



    [entities 0.1.1 without project view]



    [entities 0.1.1 with project view]


    [entities 0.3.0 without project view]


    [entities 0.3.0 with project view]
     
    Last edited: Dec 7, 2019
    5argon likes this.
  2. BackgroundMover

    BackgroundMover

    Joined:
    May 9, 2015
    Posts:
    224
    Did you try disabling Domain Reload in the "Enter Play Mode Settings"?
    Edit -> Project Settings -> Editor -> Enter Play Mode Settings -> Domain Reload unchecked
     
  3. dthurn

    dthurn

    Joined:
    Feb 17, 2015
    Posts:
    77
    I see a big difference too (2020.1.a14 on OSX). The new fast enter play mode thing does fix it, but it's currently throwing an
    Assertion failed on expression: 'sceneRanges.empty()'
    error for me when I use it...
     
  4. pocketpair

    pocketpair

    Joined:
    Jul 7, 2015
    Posts:
    72
    @vestigial
    @dthurn
    Hi, thank you for your comment. I know Enter play mode settings with disabling domain reload however this is still a lot of restrictions especially static things.
    In current project, I don't want to use it since there cloud be a lot of bugs not only domain reload but also entities.
    I can't distinguish whether some error is caused by disabling domain reload or entities or application bug.
    Restrictions
    https://blogs.unity3d.com/2019/11/05/enter-play-mode-faster-in-unity-2019-3/

    Even if without Enter Play Mode setttings, the performance should be same with entities 0.1.1.
     
    Sylmerria likes this.
  5. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    676
    For the static things you want to reset you should follow these instructions.
    Add [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] to a static method on Monobehaviours and Systems where you want to reset your static data.
     
  6. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    A project I just started working on faced a similar issue. It's not directing related with entities though, just the new asset database v2 was making our project take twice as long to both load as well as compile.

    Project is too old / big (and I just started working on it) to support no domain reloading which really seems required for asset database v2.

    Luckily this project isn't using scene conversion which is what entities is dependent on for asset database v2 so I stripped all of that out of the entities package and reverted us to asset database v1.

    Most people going to be out of luck on this though if you use scene conversion.
     
  7. pocketpair

    pocketpair

    Joined:
    Jul 7, 2015
    Posts:
    72
    @GilCat
    Hi, I know it. But for example, in my main project, there are a lot of unity asset store's assets. Sometimes it's hard to use new fast enter play mode.
    Even if that, entities 2.0 and 3.0 SHOULD BE same performance with 1.0 in the time of entering play mode.

    @tertle
    Hi, thank you for letting me know about it.
    I checked about asset database v2 but both of my test cases are v2. So I don't think it related with this performance issue.
    upload_2019-12-8_19-13-5.png
     
    dzamani likes this.
  8. pocketpair

    pocketpair

    Joined:
    Jul 7, 2015
    Posts:
    72
    Here is reproduce projects.
    entities-0.1.1-no-performance-issue.zip
    entities-0.3.0-performance-issue-exists.zip
     

    Attached Files:

  9. loicbaumann

    loicbaumann

    Unity Technologies

    Joined:
    Mar 21, 2019
    Posts:
    7
    Hello @pocketpair, thanks for reporting the issue, we're investigating and will let you know as soon as we will have more info.
     
  10. pocketpair

    pocketpair

    Joined:
    Jul 7, 2015
    Posts:
    72
    @loicbaumann thank you for your quick reply. I'd like to use entities 3.0 if it is resolved in our project.
     
  11. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Ya I'm hitting this also but haven't debugged it too far, still deciding whether it's even worth tracking down or just revert. But the difference is absolutely insane. It takes almost a minute to load our main scene, it should take around 5 seconds.
     
  12. loicbaumann

    loicbaumann

    Unity Technologies

    Joined:
    Mar 21, 2019
    Posts:
    7
    @pocketpair the issue turned out to be related with the Asset Pipeline V2, it has been reported to the team and a fix will be developed as soon as possible as startup time is very important to us.
    In the meantime you can't switch back to Asset Pipeline V1 as V2 is now a requirement for the latest version of entities.

    I would personally encourage you to try and make fast enter play mode working because it totally eliminates this kind of issue, as the related code will be run only once.
     
    optimise and dzamani like this.
  13. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Ya my gut feeling was Unity was going to try and force fast enter play mode on us. It was never touted as a Unity is now going to rely on that in their own features sort of thing.


    And it's not just asset db v2. It's entities. Even if the core issue is the asset db entities chose to use something that triggers it.

    This isn't a small thing. Even projects like ours which have minimal dependencies on third party stuff we still have a few, like rewired, odin inspector, vegetation studio. And I'm sure those will fail somewhere. Not too mention our own roughly 100k LOC code base with shared projects using statics and all.

    It really feels like a giant screw you this is something we want so live with it. Either that or your teams really don't get how big of a deal this is for some projects. Not a trivial thing. I can't just go plaster runtime initialization everywhere, I have to go re engineer a proper design for statics and singletons spanning multiple shared C# projects. Debug and review hundreds of unit tests.

    And until I do that, I'm stuck in time with DOTS.
     
  14. loicbaumann

    loicbaumann

    Unity Technologies

    Joined:
    Mar 21, 2019
    Posts:
    7
    To be clear: the current perf issue is not normal and will be resolved asap. Faster enter play mode is currently the only way I can think of as a workaround.

    In any case, fast enter play mode is an awesome feature, I debug as much as you guys everyday and the time saved is huge!
    I can understand it doesn't work with some assets, but maybe it is worth investigate to fix them considering the time saved afterward.
     
    optimise, dzamani and florianhanke like this.
  15. dthurn

    dthurn

    Joined:
    Feb 17, 2015
    Posts:
    77
    Would this also affect script compile time? Even without entering play mode, changing any C# code causes Unity to hang for 5+ seconds...
     
  16. jdtec

    jdtec

    Joined:
    Oct 25, 2017
    Posts:
    302
    Last edited: Dec 11, 2019
  17. pocketpair

    pocketpair

    Joined:
    Jul 7, 2015
    Posts:
    72
    @loicbaumann
    Hi, thank you for your quick investigation.
    I'll wait it for next update (Asset pipeline v2). As a workaround, I've started to use fast enter play mode. Actually it is awesome:) (But I needed to modify some assets, especially SRDebugger, most popular debug console in app)
    I changed this thread title to "Entities 0.2 and 0.3 Performance issue for entering play mode due to Asset Pipeline v2 dependency"

    By the way, actually I also feel similar slow compilation with @dthurn and @jdtec.
    I'm not sure whether it is caused by fast enter mode or entities 3.0 (or Asset pipeline v2)
     
  18. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    966
    Thanks for the info, yeah code compilation takes a looot longer. Kind of lame with all the packages we have to use.

    From the thread, Asset pipeline v2 has some bug that makes it slower. Hope they fix it soon.
    Does anyone know what the requirements are for fast loading because in the multiplayer project it didn't really work. It worked with enabling domain reload but then it was as slow as before so I don't see the purpose. Fast loading seems like a bandage for a deeper problem.
     
  19. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    @loicbaumann is there a bug report on this so we can track the resolution?
     
  20. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    Can I have the issue tracker for this case?