Search Unity

Official DOTS development status and next milestones – June 2022

Discussion in 'Entity Component System' started by LaurentGibert, Jun 6, 2022.

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

    bogdancoder

    Unity Technologies

    Joined:
    Feb 6, 2017
    Posts:
    29
    I am not aware of significant changes to the runtime data format. It is the pipeline itself that is made deterministic.
     
  2. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    894
    The client/server baking for netcode is still a work in progress. I don't have yet a full picture about how is going to looks like. The problem though is multi-faced since, depending on the build type, a component may still need to be baked in the scene (i.e client/server build) and then removed at runtime. But in general, for a specific client/only server/only build a support will be provided to let the baking skip component that aren't meant to target the destination world.
     
  3. TheOtherMonarch

    TheOtherMonarch

    Joined:
    Jul 28, 2012
    Posts:
    866
    What I meant about serialization is that not all serialization formats are deterministic, JSON serialization for example.

    Also, my understanding is the old conversion systems did not even use burst. So any math you did in them was non-deterministic.
     
    Last edited: Sep 23, 2022
  4. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,264
    It doesn't care about the authoring type. Just the inputs for blob generation.
    More or less. It gets executed inside the Execute method of an IJobFor job.
    For the "simple" version of Smart Blobber, yes. The advanced version also allows for deduplicating inputs, which gets used for meshes and audio sources.
    Yes. Blobs are ready before the main IConvertGameObjectToEntity callbacks happen. Though I could have made a custom callback later in conversion to do the main thing.

    That's the issue. Whatever requests the blob asset has the context of where that asset goes. If I have to split the request and post-process into two separate objects, then I have to transfer that context somehow. I want to make it easy to transfer that context with as little boilerplate as possible (or make the transfer unnecessary) because I expose the "Smart Blobbers" as public API for a library and I want that library to be easy to use.

    The other option is to not have parallelism or input deduplication, but that would drastically increase baking times and be the opposite of "performance by default".
     
  5. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    962
    As I see this thread is very active recently, I've to ask, what about other stuff you can tell us will be in 1.0?
    Personally I'm not too excited about the Baker or Aspects. Great features to have, don't get me wrong, it's just talked about a bit too much and now I'm thinking is 1.0 everything about authoring and aspects?

    So, maybe can you talk about other improvements outside of Bakers, Aspects and Enabled/Disabled comps that you are most excited about?

    Some more specific questions I have:
    - how is the enabled/disabled comps going? will it hit for 1.0? (also something I'm not too interested in but I still want to know)
    - core performance improvements?
    - SystemBase performance improvements?
    - burstable ECBS for usage in ISystem
    - will CreateEntityQuery be burstable in ISystem?
    - Will NativeContainer be finally usable in ISystem?
    - Have NativeContainers seen the rewrite yet?
    - Did any NativeContainers improve in performance? Some are, not great, for parallel processing and kind of a pitfall unless you know.
     
  6. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,264
    Have a read through this. https://github.com/Unity-Technologi...d7bf2806af04fc9fa31dc52535/Ported/combat-bees The answer is "yes" to most if not all of your questions.
     
    Enzi, elliotc-unity and Anthiese like this.
  7. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    For this 1.0 Baker I still have question to ask. I want baker code to available at editor only. Does Baker now able to create editor only assembly definition without getting any compile error at baker authoring monobehavior? At 0.51, u will get this issue especially when u are using editor only API and u need to set assembly definition back to include all platforms to fix it. It seems like after u try to use git to quickly switch to a commit then after that u will see authoring monobehavior script has warning saying compile error and reimport the folder that has related authoring code and assembly definition can't fix it.
     
    Last edited: Sep 24, 2022
    andrew-lukasik likes this.
  8. desertGhost_

    desertGhost_

    Joined:
    Apr 12, 2018
    Posts:
    260
    So will IConvertGameObjectToEntity be auto-converted to use the Baker API, be deprecated with an expiration date, or outright removed in 1.0?
     
  9. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    @bogdancoder 1) Another question I would like to ask. Is that 1.0 release not longer able to use GameConversionSystem to do advanced authoring? If yes, what is the equivalent API to do the same thing at Baker?

    2) What's the API changes for blob asset authoring conversation from 0.51 to 1.0 Baker? Is that become much more easier to do it?
     
    Last edited: Sep 25, 2022
  10. Aede-unity

    Aede-unity

    Unity Technologies

    Joined:
    Sep 2, 2022
    Posts:
    3
    I would not recommend adding blob assets in a baking system. The reason that Baking is correct (compared to Conversion) is that it keeps track of dependencies and what is added in a baker. When a change is made, everything in the baker is reverted before the baker is rerun to reflect the changes.

    When a blob asset is added in a baker, it is added to the list of things that are tracked and as such it will be reverted and cleaned up when changes are made. Right now, baking systems do not have the same level of tracking: the blob asset will not be tracked, reverted or cleaned up when a change is made that reruns the baking system.

    With that being said, I think that your use case can handled by a baker, and it might even make your life easier. The Baking API adds a blob asset to its dependency tracking by taking the BlobAssetReference. So you still have to create a blob asset and generate its BlobAssetReference. This can be done in a Job inside the baker. I saw in your example, you keep track of game objects to avoid duplication and disposing on rerun. If you us the API baking provides, this is handled for you. You only have to create the blob asset and the BlobAssetReference and add it to the baker, and all the other things are handled for you. However, this off course creates some overhead if you want to avoid building the blob asset if it already exists (I'll come back to that later) but it makes it a lot easier to use.

    I am currently creating samples to show how blob assets work in Baking, and this what is described above is very close to a sample I have. I haven't tried to make my Job run in parallel, so I can't comment on how that would work (yet, I think I will alter my sample to reflect that). The only difference I can see is that your conversion system seems to run on multiple authoring components, and a baker only handles one. However, I couldn't find a reason why this couldn't be changed to work with bakers. Let me know if you do see problems with that and what those are.

    As for the pre-baker deduplication, we avoid deduplication by generating hashes for each blob asset. Because of this, you first need to create the blob asset completely as the hash is created from the content. Only then can we check for duplications and resolve them. However, if you want/need more control, you can choose to use custom hashes. If you do this, you have to make sure yourself that the hashes are correct and identifying. If you have theses hashes up front, you can then use the Baking API to check if something with that hash already exists in Baking-tracked blob assets. This way you can avoid building a blob asset, while still making use of Bakings tracking and handling.

    I hope this also answers this question somewhat. This is a rather complicated case, but I do believe it showcases that it has become easier to use.
     
  11. Elapotp

    Elapotp

    Joined:
    May 14, 2014
    Posts:
    98
  12. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,264
    I want to thank you for listening to me and being involved in this discussion. I've felt conversion/baking has been underrepresented in these forums. And while the simple and common use cases are fairly straightforward, I've always felt the APIs fall apart with increase complexity that requires rapid iteration.

    Actually, that's just because under the hood Smart Blobbers use BlobAssetComputationContext API, and that API requires GameObject references. What do the GameObjects get used for? Not sure. I don't think it works as intended though, because the BlobAssetStore seemingly gets dropped on the floor between conversions.

    The actual code flow for Smart Blobbers is as follows:
    1) Early setup callbacks
    2) Setup filtering
    3) Invoke filter function
    4) Remove filtered out instances and in the case of the batching variant, remap duplicates
    5) In the case of batching API, invoke post-filtering callbacks
    6) Run parallel build blobs job
    7) Extract hashes from blobs and feed them into BlobAssetComputationContext. Note: At this point the BlobAssetComputationContext API assumes that I have hashes but haven't actually built the blobs yet. So rather than use the API to find out which blobs I need to build, I use the API to find out which blobs I need to keep.
    8) Dispose unused blobs and fulfill handles

    What you describe is what I think BlobAssetStore.AddUniqueBlobAsset() did, which was not scalable.

    There are three issues in what you describe that my solution solves.

    First, I differentiate between pre-generation input deduplication and post-generation blob deduplication. Pre-generation is like a Physics broadphase algorithm. It is course-grained, sometimes produces false positives, and is cheap. Instead of trying to compute a deterministic identifying hash which is often just as expensive as computing the blob asset itself, it simply has to look at all the inputs passed into conversion and identify which ones are guaranteed to generate the same blob asset. That means nondeterministic inputs like UnityEngine.Object.GetInstanceID() are viable. The Filter function in the Triangle Soup example shows exactly this. GetInstanceID() is never seen by BlobAssetComputationContext. Only the truly deterministic hash generated from the blob asset itself makes it to BlobAssetComputationContext.

    Effectively, this is an optimization that comes from batch reasoning. Bakers don't appear to have any batch reasoning capability. Plus, a baker is locked into a single type of authoring component while my solution allows many different authoring components to request the same type of blob asset. That's my second issue with the Baker design.

    Yeah. That's actually the crux of my third issue with the Baker design. Generating a single blob asset in parallel is most of the time not practical. However, generating multiple blob assets in parallel to each other is practical. That only works if I can gather all the blob asset requests for a specific blob type and batch-reason about them. It also opens the door for other optimizations, such as using one large MeshDataArray instead of many individual instances, which you can see in the Triangle Soup example's PostFilter() method. Again, the lack of batch reasoning is removing massive optimization potential.

    I hope my assumptions are wrong about bakers, but as I see it now, I'm mentally preparing for a significant regression in blob asset generation. :(
     
  13. bogdancoder

    bogdancoder

    Unity Technologies

    Joined:
    Feb 6, 2017
    Posts:
    29
    GameConversionSystems and the interface IConvertGameObjectToEntity are being removed in 1.0. This is a breaking change.

    The equivalent API involves writing a baker for the component type. When more advanced baking is necessary, you can create a baking system for further processing.

    The existing conversion code will have to be ported to the baker + baking system API. Our experience doing this internally has been positive - it can be straight forward to do the conversion in most cases when only the IConvertGameObjectToEntity is used. GameObjectConversionSystems may require some work to refactor, depending on the setup. Specifically, you can prepare by ensuring that you do not rely on runtime conversion APIs and by setting up your scenes using subscenes (the ConvertToEntity component is also being removed).
     
    optimise, psuong and Anthiese like this.
  14. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    857
    How will companion gameobjects workflow change in 1.0?

    Will they be internally pooled or will instantiate/destroying an entity with a companion gameobject also result in GameObject.Instantiate/Destroy(and the resulting gc from such an operation)?

    Also which api's in 1.0 will specifically not have a api updater from .51 and will need to be manually updated ourselves?
     
    Last edited: Sep 26, 2022
  15. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    Oh wait. Since both GameConversionSystems and ConvertToEntity component are being removed, does it means there's no way to do runtime conversion at player runtime build even u create a baking system for further processing? So 1.0 baker now become editor only authoring tooling? Or u still can write both GameConversionSystems and ConvertToEntity component equivalent yourself for runtime purpose that they are removed to avoid promoting bad practice for ConvertToEntity component?

    Are there any breaking changes for EntityManager related APIs in 1.0 to do something outside of Systembase/ISystem? General use case like query required entity and then add/remove/update component to entity to specific world i.e. client/server world at MonoBehaviour.
     
    Last edited: Sep 27, 2022
  16. LaurentGibert

    LaurentGibert

    Administrator

    Joined:
    Jan 23, 2020
    Posts:
    173
    Hi everyone, there is a new release for ECS, more details over here!
     
    Anthiese likes this.
Thread Status:
Not open for further replies.