Search Unity

What is DOTS good for so far?

Discussion in 'Scripting' started by uniMaxi, Sep 29, 2021.

  1. uniMaxi

    uniMaxi

    Joined:
    Mar 10, 2013
    Posts:
    15
    I'm currently building something like a unity voxel engine for a minecraft-like game and am trying to figure out whether i actually need DOTS for anything. I haven't gotten very far yet, but i am also not sure why i would need DOTS at all. It doesn't seem to help much with dynamic meshes (which are currently the biggest headache) and, to be frank, the only part of it that seems appealing at all are native containers.

    Are there any particular use cases in general where DOTS proved very useful so far (even outside of specifically voxel engines)? If not the whole package, then some aspects of it? Like, where specifically is Burst Compiler awesome or even irreplaceable? What about entities and systems? What about jobs?

    Would appreciate any sort of feedback in that regard.
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    DOTS is intended for situations where you have huge numbers of independent objects that need to perform well and take advantage of multithreading. I think you're correct that mesh generation is not optimal for it, because that's a self-contained algorithm that's relatively easy to make threaded without using DOTS.

    If you want to simulate lots of things in the world - if trees grow, animals/creatures/enemies crawl around, that sort of thing - that's where DOTS would be advisable. You could implement those things as regular objects and have maybe a hundred creatures running around with good performance, or you can implement the creatures in DOTS and have 10,000.
     
    exiguous likes this.
  3. exiguous

    exiguous

    Joined:
    Nov 21, 2010
    Posts:
    1,749
    Note: This topic is better suited for the DOTS subforum instead of the general scripting forum.

    This may be of interest for you: https://forum.unity.com/threads/a-voxel-game-prototype-in-unity-ecs.852610/
    I also suggest to search the previously mentioned DOTS subforum for keywords like "voxel" and "minecraft" to read the discussions about this topic.
    And you don't need it. The question is if it helps you and makes your life easier or harder.

    Have you considered using the new Mesh API already?

    DOTS is the result of Unity's "performance by default" initiative. So if you want to do more game with less resources it is your thing.
    Edit: A good presentation about the performance improvements gives this video.

    Burst allows to a better parallelization of code (SIMD) and produces highly optimized code. A good tutorial to get you started.

    In "normal" OOP programming you have lots of references between objects which lay scattered in memory. So when you "follow" such a reference for example to access the transform of your object the memory where it lays must be fetched from RAM which is pretty slow. Because the required object cannot be found in CPU-cache this is called a cache-miss. DOTS-ECS applies a pattern called Data oriented design to pack the data tightly in memory so those cache misses are minimized. This requires a new thinking about data, it's layout, access patterns etc.. So many people coming from OOP have a hard time to "transition" in this new thinking scheme. The data layout is often compared with database tables.

    Single core performance has reached a plateau and will probably not improve significantly in future. But the number of cores will raise steadily. So for more performance you have to parallelize your calculations.

    There is a little naming confusing. I guess you mean the ECS part of DOTS. DOTS itself consists of the new Jobs system, the Burst compiler, a new math library (SIMD-capable with Burst) and ECS. The former parts are more or less useable right now. DOTS-ECS is not. UT has gone completely silent on it's development without explanation at start of the year which is controversely discussed. So currently I would advise against using it since it's future is unknown. Maybe the whole thing is already scrapped. Who knows when there is no official statement?

    ECS has quite some technical problems. Some of which are that you are locked at Unity version 2020.3 when you want to use it. You get no updates for URP which causes further issues. Most "systems" like animation, audio, UI etc. are not supported yet. Documentation, examples etc. are lacking. So the state is very experimental and you must be willing to "work" through such issues. If you want to learn and experiment go ahaead. If you (commercially) rely on the result better to wait a bit more how it develops (if at all).

    It definitely is a step in the right direction. But how UT handles this (no updates, no communication) is highly questionable. So my advise would be to utilize the other parts of DOTS and leave ECS out until it is "officially" support and talked about again. When you adopt the current 0.17 version chances are high that you need a complete rewrite when new stuff comes out. I have put my ECS project on hold for this exact reason.
     
    Last edited: Sep 29, 2021
    Bunny83, uniMaxi, Lekret and 2 others like this.
  4. uniMaxi

    uniMaxi

    Joined:
    Mar 10, 2013
    Posts:
    15
    @exiguous
    Thanks for the great reply and especially for the reference to the new Mesh functionality.

    Aside from meshes, I understand both Burst compiler and jobs are eminently useful, whereas the system-entity thing looks more like a liability at this point. So I'll focus more on Burst and Jobs and forget the rest for now.

    Thanks again!
     
    SirIntruder and exiguous like this.