Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Enter the 2020.2 Beta Sweepstakes for a chance to win an Oculus Quest 2.
    Dismiss Notice

How low-level to achieve the benefits of using DOTS?

Discussion in 'Data Oriented Technology Stack' started by Nyanpas, Sep 18, 2020.

  1. Nyanpas

    Nyanpas

    Joined:
    Dec 29, 2016
    Posts:
    282
    I've started working on getting my project more and more over to ECS and DOTS now, especially for the NPCs and vehicles, however I am noticing that things aren't as straight forward as it was with Monobehaviour and I end up spending a lot of time looking up what I can do and how. I also find I am writing a lot more code, but also that I can do more in more levels. Which then again brings me to starting to look into loop vectorization and such, and suddenly I am now doing optimisations I have never really looked into that much before, but seems to be absolutely key to getting the few extra% of performance boost needed to make the conversion worth it. Had I gone with Monobehaviour all the way my game would have been released last year, not because I am more familiar with it, but because of how limited it is. I just need to put the right shape into the right hole and hammer it in with the squeaky hammer like I always do, unlike with DOTS where I have to put on a magnifying lens to assemble the Fabergé egg's finer pieces using a precision tool.

    I would at least expect a more "adaptive" compiler to understand that putting [WordInBrackets] would be a silver bullet, but it seems we are not there yet. I am happy I am doing my game in my spare time, because at least I don't have a deadline over me, but I do think that for DOTS to be more mainstream-accessible, there could be a bit more implicit conversions happening that we wouldn't need to think about. Yet, I could be wrong, and would love to be proved wrong.
     
  2. brunocoimbra

    brunocoimbra

    Joined:
    Sep 2, 2015
    Posts:
    469
    This statement is actually false most of the time. DOTS is about performance by default, you shouldn't really care about doing micro-optimizations all the time, you should only optimize when there is a performance issue (if any).

    Caring about loop vectorization is only worth in code involving really heavy computation that is being done frequently, in any other case just ensuring that your jobs are burst compatible and avoiding executing stuff on the main thread (which is not totally bad sometimes) will already grant you the DOTS benefits.

    From personal experience, my recommendation is to just code the stuff the way you need for them to behave correctly and care about optimizations only when issues come up. In DOTS refactoring and late-game optimizations are much easier to do anyway, so there is no reason to go nuts from the beginning.
     
    florianhanke likes this.
  3. Nyanpas

    Nyanpas

    Joined:
    Dec 29, 2016
    Posts:
    282
    The removal of the overhead from using Monobehaviour's gameobjects and multithreading are the only reasons I want to use DOTS. This is more about ease of access to achieve the minimum needed to get the performance benefits. If you have a somewhat involved non-linear game, DOTS should be the optimal approach (even if it feels like I am writing API-code Unity should have provided).

    And it seems complex systems in parallel is exactly what DOTS is for to me, as it opens up a lot beyond what you can achieve with Monobehaviour. I am doing a mesh generator and triangulator that needs every bit of performance increase to be able to be executed during run-time, so anything I can do to make it work is something I will do, and this is again, only possible with DOTS. All the performance issues have already come up, hence DOTS.
     
    brunocoimbra likes this.
  4. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    1,779
    Scalar bursted code still demolishes il2cpp code. Often times it beats the equivalent C++ code. There's a difference between "performance by default" and "maximum performance by default". Unity promises the former, not the latter. However, Unity also promises the "ability to achieve maximum performance" which you can also do by digging into the low-level details. It is super easy to get sucked into trying to do the best most optimal thing ever, but sometimes you just have to say "good enough" and start something new. DOTS gives people that option.
     
  5. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,127
    Ashkan_gc likes this.
  6. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,127
    I'll also say that we are now spending more time in the DOTS team figuring out how we can get writing DOTS game code to be on par with MonoBehaviour in terms of ease of use / simplicity.

    Our goal is essentially that making performance by default, means that it can't be harder to write DOTS game code than MonoBehaviour code. While being committed to having the same performance compared to what you see with DOTS today.

    For new users it might require learning as slightly different way of writing code, but once learnt it should not be more difficult or be less effective at prototyping code in any way. We also believe it must be possible to write DOTS code even for users who identify as scripters / designers. And obviously it must meet the performance / determinism / scalability / netcode requirements that one has come to expect from DOTS already.

    We have a plan and I am quite confident we can pull it off. More on this soon.
     
    Last edited: Sep 18, 2020
  7. Lieene-Guo

    Lieene-Guo

    Joined:
    Aug 20, 2013
    Posts:
    412
    The lack of Document for DOTS is also a reason the people code game with DOTS much slower than Mono. For me, the time spent on digging into DOTS source code is about the same as coding. If test code is not counted, My game logic coding time could be only about 20% percent of total work time.

    I have been working with Unity for 10 years. And I almost never post in unity forum Until DOTS. As here is the only source of insight.
     
    Last edited: Sep 18, 2020
    Ghosthowl and Nyanpas like this.
  8. Nyanpas

    Nyanpas

    Joined:
    Dec 29, 2016
    Posts:
    282
    This is very good new. :3

    I am "new" to DOTS, yet the general way of thinking with regards to how to approach data management makes sense as far as I can tell compared to previously done approaches.

    One thing I have had in mind is how to look up objects based on similar traits, so you build up a description of an object with traits (components) that define the object. With filtering in DOTS this has the benefit of finding for instance "every object that is round and heavy within this size". It really helps the way it is implemented, as looking this up is a lot faster and smoother with ECS. I can ultimately only see benefits to this for the project I am working on.
     
  9. TheOtherMonarch

    TheOtherMonarch

    Joined:
    Jul 28, 2012
    Posts:
    128
    I started learning DOTS off and on. The documentation is no were near MonoBehaviour. My OOP code already had a fair bit of functional programming paradigm mixed in. I think most of my OOP code is going to end up as static functions with data shared between function calls in native data structures. I hope that does not create too much over head.

    Porting my OOP code is going to be nontrivial. I kind of want to start soon but I am divided.
     
    Last edited: Sep 18, 2020
  10. Nyanpas

    Nyanpas

    Joined:
    Dec 29, 2016
    Posts:
    282
    For me the final push was performans. I tried everything, but having to spread load across frames just seemed like shooting myself in the foot when modern architecture supports parallel. Of course I could do compute shaders, but that has its own issues and did not seem like it was a good fit for what I am currently trying to do. However, in time I could do that as well for specific parts.
     
unityunity