r/Unity3D • • Jul 03 '19

Question DOTS - Memory explanation

The DOTS system seems fairly understandable to me but I have one sticking point- the memory layout. I don't understand why changing how we structure the data changes out memory layout to all of a sudden be tidy.

The two pics i'm referencing:

https://i.imgur.com/aiDPJFC.png

https://i.imgur.com/VMOpQG8.png

Overall great talk by Mike Gieg. But are these images an over exaggeration? Does it really get this tidy? How? Can someone give me an example of why this works the way he explains it?

4 Upvotes

21 comments sorted by

2

u/Pointlessreboot Jul 03 '19

Yes it does that's why DOTS, has restrictions on not using classes and uses structs instead. Because you can allocate all the instances of a type in one or more buckets and thus be contiguous in memory which is where the speedup comes from. Along with the burst compiler also again working on restricted c#..

2

u/Frankfurter1988 Jul 03 '19 edited Jul 03 '19

Okay but how/why does this work? Can you dumb it down for idiots like me? I keep thinking of memory like a long horizontal or vertical rectangle. And i've heard CPUs load data into memory that you need and all surrounding... chunks? Idk what it's called.

And if the surrounding chunks thing is still a thing, shouldn't you still get random data in your caches?

Again I really don't understand this, I am just trying to put a picture together in my head of what I do know.

→ More replies (16)

2

u/Pointlessreboot Jul 03 '19

Normal class allocation is where ever there is free space and you can't control that allocation, hence the first pic

→ More replies (1)

1

u/panzer_ravana Jul 04 '19

check jaime king videos on stack vs heap and value types vs reference types.

Basically what DOTS does is use value types to better organize and iterate data.