<aside>
👋🏽 Nitesh & David’s CTIN 583 Deep Dive Exploration into Unity DOTS (Data Oriented Technology Stack)
</aside>
Why DOTS
- Today’s computers are very very very very very fast
- Most software is slow
- We experience this everywhere we look: on the web, on our PC and many devices we interact with — computers have never been faster but somehow it rarely feels that way
- How fast our software is depends greatly on how the data is organized (in memory)
This is what memory looks like in object oriented programming (standard Unity MonoBehaviors)
- DOTS is a new architecture that Unity is building in order to extend the capabilities of the engine
- The idea behind DOTS is to create ‘performance by default’
- This means helping creators write efficient code that is multi-threaded and takes advantage of hardware-specific optimizations that were traditionally reserved for experts
This is what memory looks like in a DOTS project — like data is stored with like data (in Chunks) so it can be processed quickly and efficiently
Overview of the architecture
-
Because DOTS is a fundamental paradigm shift for the Unity engine it replaces much of Unity’s built-in functionality
- From game objects (now entities) to physics, to networking, animation and others
- Writing code for any of these systems at a minimum requires learning new function names
-
Our focus was on the core system called the Entity Component System
-
Building Worlds
<aside>
1️⃣ World (Simulation)
- EntityManager
- Component Systems
- Initialization (group)
- Simulation (group)
- System1
- System2
</aside>
<aside>
2️⃣ World (Rendering)
-
EntityManager
-
Component Systems
- Initialization (group)
- Simulation (group)
- System3
- System4
</aside>
-
Strongly segregation of data and functionality
-
In essence, you still do the same thing — find objects and their components and do stuff to them (transform their data)
-
When you write DOTS code you mostly use a type of code construct called Lambda expression
If you understand Lambda expressions you are smarter than we
Using DOTS
- What can you do with dots?
- Cubes, cubes are more cubes...
- But DOTS is not just about quantity!
- Because the data is organized efficiently, it can be transformed efficiently — many objects can changed or updated without sacrificing performance
- In this example, all of these objects have full dynamic physics interactions with each other
- We’re able to change properties of all 35,000 entities at once!
Here is the same code spawning 25 cubes per frame without issue on a more modern laptop. We were able to run this continuously without despawning any of the cubes with only the slightest slowdown even with upwards of 35,000 entities active at one time.
Here is the same code spawning 25 cubes per frame without issue on a more modern laptop. We were able to run this continuously without despawning any of the cubes with only the slightest slowdown even with upwards of 35,000 entities active at one time.
Entity Debugger showing off the amount of entities being generated as well as the various physics systems being applied to each one. (Updated since Entities .050)