Search Unity

Official Experimental Entities 0.50 is Available

Discussion in 'Entity Component System' started by mfuad, Mar 16, 2022.

Thread Status:
Not open for further replies.
  1. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    I can get 90% performance in editor if I turn off absolutely all safety checks PLUS THE IMPORTANT THING of switching to release mode. Switching editor from debug to release alone nearly doubles my fps.

    Some random numbers,
    normal development environment : 30-35fps
    everything turned off + release mode : 80-85fps
     
    elliotc-unity, Elapotp and Anthiese like this.
  2. Elapotp

    Elapotp

    Joined:
    May 14, 2014
    Posts:
    98
    Would be nice to disable DOTS safety checks when switching to release mode (or at least to have such a toggle)
     
  3. elliotc-unity

    elliotc-unity

    Unity Technologies

    Joined:
    Nov 5, 2015
    Posts:
    230
    Not anytime soon. Fundamentally, the problem is that the editor is running the game code in the same process and sharing the same main thread as a bunch of editor code. We have done a ton of work to improve editor perf for 1.0, but some of that work will also improve player perf, so that moves the goal posts.

    It actually depends; some of the slow safety checks in 0.50 / 20.3/ 21.3 (e.g. many of the job scheduling ones) are actually in C++, and we independently optimized those significantly for 1.0 / 22.2.

    The editor is definitely supposed to be able to use all the cores if you have enough work for all the worker threads, and you haven't set the job worker count to less than your core count. That said, it is hard for many games to keep all the cores fed, for various reasons. I would think what is happening is if you look at a profile, worker threads are sitting idle because either a) there are no available jobs to schedule, OR b) you are running on a machine with a bunch of cores, and/or you are scheduling too many small jobs for the old job system to handle and therefore you're drowning in job scheduling overhead.

    1.0 will significantly help with b), and somewhat less (arguably not at all? kind of depends how you count) with a)

    Uh, no idea. I haven't heard much about them internally lately, whereas for example I am thoroughly aware of dots animation making ongoing progress (albeit not for production-readiness at the same time as entities 1.0).

    One issue Unity has had in the past with e.g. navmeshes is that AI stuff is often really specific to each game, and it's pretty hard to make a system that is useful for many different kinds of games. Navmeshes predate burst & jobs, and so by being written in C++ they had access to performance that was mostly unavailable to user code.

    But now we do have burst & jobs, and so if I were making a dots game today, I would personally be pretty inclined to roll my own rather than use something Unity put out anyway.
     
  4. elliotc-unity

    elliotc-unity

    Unity Technologies

    Joined:
    Nov 5, 2015
    Posts:
    230
    This makes no sense to me; release mode does not reduce safety, it just means you can't debug. I agree if you really want to go fast you should have both, but the reasons you are OK being in release mode are not the same as those you are OK turning off the jobs debugger & burst safety checks.
     
    charleshendry, JesOb and Elapotp like this.
  5. elliotc-unity

    elliotc-unity

    Unity Technologies

    Joined:
    Nov 5, 2015
    Posts:
    230
    Just for science, what is your framerate in an il2cpp non-development master build? I would think it would be quite a bit higher than that assuming you're still CPU-limited, and so the editor would then not be at 90% of player perf again.
     
    JesOb likes this.
  6. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    We only build il2cpp and I get around 85-95 fps in our published release.

    I should say though I am definitely more GPU than CPU bound so I guess if this was not the case results may vary.

    Anyway my point was more you can significantly improve your fps in editor turning everything off if required. I wrote a single menu button to toggle all this for our artists etc so they can get a much better experience.
     
    Last edited: Jun 14, 2022
    Luxxuor and elliotc-unity like this.
  7. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    Awesome. I believe the editor slowdown issue is caused by dots netcode which is really resource intensive at editor. When enter playmode, it needs to run client and server at the same time plus editor overhead which make it really slow at real production project. Even u off all the safety check, it still just only increase few fps. You can see slowdown when u are using laptop which has really weak CPU. You can to test laptop with CPU i7-7700HQ or equivalent with complex production level dots netcode project. But you still can get nearly 60 fps at desktop pc. I think I can conclude that u will need really high clock speed CPU to reach solid 60 fps at editor.


    Actually all the systems I use Run() to run on main thread since it's mobile dots netcode project. I believe most of the system still need to run on main thread even I upgrade the project to dots 1.0 release in future as I believe mobile phone still faster to run on main thread for most of the simple systems even job schedule overhead has been improved significantly.

    Ya. I already know this from somewhere. Hopefully I can get a preview before 2022.2 enters 2022.3 LTS stage.

    Currently I dun really have much time and resource to roll my own AI solution. And also I believe currently there is no such solution at Unity Asset Store yet. I really hope Unity official can fill this gap really soon as I need the solution that has long term support. It will really weird if Unity official not investing official dots ai solution which is really essential feature for game development.
     
    Last edited: Jun 15, 2022
    elliotc-unity likes this.
  8. skiplist

    skiplist

    Joined:
    Nov 9, 2014
    Posts:
    47
    As someone coming from 0.17, did 0.50/0.51 receive any improvements regarding the job scheduling overhead or is this all in 1.0?
     
  9. elliotc-unity

    elliotc-unity

    Unity Technologies

    Joined:
    Nov 5, 2015
    Posts:
    230
    I don't think there are any. The improvements I know about are all in the core engine; we had to rewrite the core job queue implementation from scratch, since the old queue was fundamentally never going to cut the proverbial mustard. And, a rewrite like that is never going to get backported to an LTS, because risk.
     
    Luxxuor, Clonkex, JoNax97 and 6 others like this.
  10. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    Just curious. The rewrite still at C++ land or it's moved to C# land and burst it?
     
  11. elliotc-unity

    elliotc-unity

    Unity Technologies

    Joined:
    Nov 5, 2015
    Posts:
    230
    C++. It also is used by all kinds of C++ code internally, and conforms to the same C++ interface that the old one did, as well as the same C# interface.
     
  12. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    I see. There are still overhead that call C# then C# calls C++ that I believe it's called marshalling. Will the overhead quite high or you already have solution to solve this problem?
     
  13. elliotc-unity

    elliotc-unity

    Unity Technologies

    Joined:
    Nov 5, 2015
    Posts:
    230
    The C# overhead is actually not mostly from marshalling iirc; I believe a lot of it is creating "job reflection data" which is some metadata we need for various purposes both for safety (for when the jobs debugger is turned on) and for knowing what function to call to execute the job,* and then when burst is ready, which function to switch to.

    We got around this by a) moving most of it to an early-init function that runs at startup for all schedulable job types (which hurts startup JIT cost in mono, but helps a lot more post-startup than it hurts), and then b) bursting schedule sites.

    * this is not actually your personal Execute function, which a) is how ijobparallelfor can work, and b) is how burst can burst job functions despite only being able to burst static methods; the actual function is here (in the case of ijobparallelfor) https://github.com/Unity-Technologi...4/Runtime/Jobs/Managed/IJobParallelFor.cs#L35
     
    mloveall, JesOb, Anthiese and 3 others like this.
  14. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    @elliotc-unity I still have some questions want to ask.

    1) Will mega-chunks & tiny chunks feature release at dots 1.0 release or later? Like mega chunk is 256kb of memory for each chunk and tiny chunk is 512 bytes of memory for each chunk. Current 16kb chunk is still there.
    2) Will dots addressable support instantiate oop land game object? Currently I'm using addressables to instantiate oop land game object at my dots netcode project. I want dots addressable support instantiate oop land game object so I dun need to maintain both dots addressable and addressable which is really troublesome.
     
  15. elliotc-unity

    elliotc-unity

    Unity Technologies

    Joined:
    Nov 5, 2015
    Posts:
    230
    Heh, I found answers to these last time you asked them, and then forgot to actually reply here.

    Not for 1.0. Dunno when after.

    Sounds like you can load a GO from a dots addressable, and then instantiate the GO from your own code. I haven't actually tried to do this myself so I don't know what it looks like, though.
     
  16. Opeth001

    Opeth001

    Joined:
    Jan 28, 2017
    Posts:
    1,117
    I plan to create a few systems at some point to keep the subscene GO references and load them at runtime so the subscenes don't save those meshes, textures... internally.
    but I think it's something the Unity team needs to take care of because it's really important for any project using DOTS, especially for mobile projects, because no one wants to submit the complete subscene as an update when only a few prefabs has been changed.
     
    lclemens and optimise like this.
  17. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    (0.51 is out for those that haven't realized)
     
    Last edited: Jun 15, 2022
  18. mikaelK

    mikaelK

    Joined:
    Oct 2, 2013
    Posts:
    284
    I have these errors on 0.51
    upload_2022-6-16_4-27-56.png
     
  19. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    Anthiese likes this.
  20. mikaelK

    mikaelK

    Joined:
    Oct 2, 2013
    Posts:
    284
    ok thanks, I'll try latest 2021
     
  21. mikaelK

    mikaelK

    Joined:
    Oct 2, 2013
    Posts:
    284
    More errors.
    upload_2022-6-16_4-57-31.png
     
  22. Krajca

    Krajca

    Joined:
    May 6, 2014
    Posts:
    347
  23. mikaelK

    mikaelK

    Joined:
    Oct 2, 2013
    Posts:
    284
    The 0.51 is according to my performance tests something like 20% slower.
    Test that used to take 10.7 ms now takes 12.89 ms.

    I was hoping an improvement

    Edit: Rerun the tests after restart. Might be that on the morning I had jobs debugger on. Now its 10.90.
     
    Last edited: Jun 16, 2022
  24. EugenyN1

    EugenyN1

    Joined:
    Jun 21, 2019
    Posts:
    17
    it seems IL2CPP build broken for project with com.unity.physics@0.51.0-preview.32 in Unity 2021.3.4.

    Code (CSharp):
    1. ExecutionEngineException: Attempting to call method 'Unity.Entities.FastEquality+CompareImpl`1[[Unity.Physics.PhysicsWorldIndex, Unity.Physics, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]::CompareFunc' for which no ahead of time (AOT) code was generated.
    2.   at Unity.Entities.FastEquality.Equals (System.Void* lhsPtr, System.Void* rhsPtr, Unity.Entities.FastEquality+TypeInfo typeInfo) [0x0001e] in C:\Unity3D Projects\My project\Library\PackageCache\com.unity.entities@0.51.0-preview.32\Unity.Entities\Types\FastEquality.cs:267
    3.   at Unity.Entities.FastEquality.Equals[T] (T& lhs, T& rhs, Unity.Entities.FastEquality+TypeInfo typeInfo) [0x0000e] in C:\Unity3D Projects\My project\Library\PackageCache\com.unity.entities@0.51.0-preview.32\Unity.Entities\Types\FastEquality.cs:258
    4.   at Unity.Entities.TypeManager.Equals[T] (T& left, T& right) [0x00028] in C:\Unity3D Projects\My project\Library\PackageCache\com.unity.entities@0.51.0-preview.32\Unity.Entities\Types\TypeManager.cs:690
    5.   at Unity.Entities.ManagedComponentStore.FindSharedComponentIndex[T] (System.Int32 typeIndex, T newData) [0x0000d] in C:\Unity3D Projects\My project\Library\PackageCache\com.unity.entities@0.51.0-preview.32\Unity.Entities\ManagedComponentStore.cs:169
    6.   at Unity.Entities.ManagedComponentStore.InsertSharedComponent_Managed[T] (T newData) [0x0000e] in C:\Unity3D Projects\My project\Library\PackageCache\com.unity.entities@0.51.0-preview.32\Unity.Entities\ManagedComponentStore.cs:148
    7.   at Unity.Entities.EntityDataAccess.InsertSharedComponent[T] (T newData) [0x00008] in C:\Unity3D Projects\My project\Library\PackageCache\com.unity.entities@0.51.0-preview.32\Unity.Entities\EntityDataAccess.cs:1574
    8.   at Unity.Entities.EntityQueryImpl.AddSharedComponentFilter[SharedComponent] (SharedComponent sharedComponent) [0x0008d] in C:\Unity3D Projects\My project\Library\PackageCache\com.unity.entities@0.51.0-preview.32\Unity.Entities\Iterators\EntityQuery.cs:1292
    9.   at Unity.Entities.EntityQueryImpl.SetSharedComponentFilter[SharedComponent1] (SharedComponent1 sharedComponent1) [0x0000a] in C:\Unity3D Projects\My project\Library\PackageCache\com.unity.entities@0.51.0-preview.32\Unity.Entities\Iterators\EntityQuery.cs:1219
    10.   at Unity.Entities.EntityQuery.SetSharedComponentFilter[SharedComponent1] (SharedComponent1 sharedComponent1) [0x00007] in C:\Unity3D Projects\My project\Library\PackageCache\com.unity.entities@0.51.0-preview.32\Unity.Entities\Iterators\EntityQuery.cs:1988
    11.   at Unity.Physics.Systems.PhysicsWorldData..ctor (Unity.Entities.EntityManager EntityManager, Unity.Physics.PhysicsWorldIndex& worldIndex) [0x000aa] in C:\Unity3D Projects\My project\Library\PackageCache\com.unity.physics@0.51.0-preview.32\Unity.Physics\ECS\Base\Systems\PhysicsWorldData.cs:37
    12.   at Unity.Physics.Systems.BuildPhysicsWorld.OnCreate () [0x00021] in C:\Unity3D Projects\My project\Library\PackageCache\com.unity.physics@0.51.0-preview.32\Unity.Physics\ECS\Base\Systems\BuildPhysicsWorld.cs:39
    13.   at Unity.Entities.ComponentSystemBase.CreateInstance (Unity.Entities.World world, Unity.Entities.SystemState* statePtr) [0x00019] in C:\Unity3D Projects\My project\Library\PackageCache\com.unity.entities@0.51.0-preview.32\Unity.Entities\ComponentSystemBase.cs:129
    14.   at Unity.Entities.World.AddSystem_OnCreate_Internal (Unity.Entities.ComponentSystemBase system) [0x00014] in C:\Unity3D Projects\My project\Library\PackageCache\com.unity.entities@0.51.0-preview.32\Unity.Entities\World.cs:331
    15.   at Unity.Entities.World.GetOrCreateSystemsAndLogException (System.Collections.Generic.IEnumerable`1[T] types, System.Int32 typesCount) [0x00095] in C:\Unity3D Projects\My project\Library\PackageCache\com.unity.entities@0.51.0-preview.32\Unity.Entities\World.cs:542
    16.   at Unity.Entities.DefaultWorldInitialization.AddSystemToRootLevelSystemGroupsInternal[T] (Unity.Entities.World world, System.Collections.Generic.IEnumerable`1[T] systemTypesOrig, Unity.Entities.ComponentSystemGroup defaultGroup, T rootGroups) [0x00092] in C:\Unity3D Projects\My project\Library\PackageCache\com.unity.entities@0.51.0-preview.32\Unity.Entities\DefaultWorldInitialization.cs:221
    17.   at Unity.Entities.DefaultWorldInitialization.AddSystemToRootLevelSystemGroupsInternal (Unity.Entities.World world, System.Collections.Generic.IEnumerable`1[T] systemTypesOrig) [0x00022] in C:\Unity3D Projects\My project\Library\PackageCache\com.unity.entities@0.51.0-preview.32\Unity.Entities\DefaultWorldInitialization.cs:286
    18.   at Unity.Entities.DefaultWorldInitialization.Initialize (System.String defaultWorldName, System.Boolean editorWorld) [0x00072] in C:\Unity3D Projects\My project\Library\PackageCache\com.unity.entities@0.51.0-preview.32\Unity.Entities\DefaultWorldInitialization.cs:147
    19.   at Unity.Entities.AutomaticWorldBootstrap.Initialize () [0x00007] in C:\Unity3D Projects\My project\Library\PackageCache\com.unity.entities@0.51.0-preview.32\Unity.Entities.Hybrid\Injection\AutomaticWorldBootstrap.cs:16
    also BuildConfiguration adding components does not work in the editor, the sub menu does not appear when selecting menu item
    upload_2022-6-16_15-32-49.png
     
    desper0s likes this.
  25. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    Oh yeah. For this I have other questions.

    1) Since HybridComponent has been deprecated, will dots 1.0 release has any hybrid solution that able to put game object into entity and able to instantiate the entity by dots addressables? So when instantiate the entity, the game object will auto instantiate together that associated with entity just like how HybridComponent does or similar.
    2) Will dots addressables support putting subscene into dots addressables like game object land that put scene into adressables?
     
  26. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,074
    Unity is suggesting Visual Studio 2022+ .
    I'm using good old 2019 should I expect some problems ?
     
  27. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    883
    I feel like it is like 2 times slower than 2019 on old hardware (laptop 2017). Other than that no issues so far.
     
  28. mikaelK

    mikaelK

    Joined:
    Oct 2, 2013
    Posts:
    284
    All my tests pass. Thanks for the long waited update.
     
  29. TieSKey

    TieSKey

    Joined:
    Apr 14, 2011
    Posts:
    225
    IIRC that bug makes the menu invisible but it's still there so u can use the arrows and enter to select things xD
     
  30. mfuad

    mfuad

    Unity Technologies

    Joined:
    Jun 12, 2018
    Posts:
    335
    Hi everyone, with the release of Entities 0.51, let's move our conversation to the release announcement. We have also shared updates regarding our roadmap here. See you over there!
     
    NotaNaN, timmehhhhhhh and JesOb like this.
Thread Status:
Not open for further replies.