C++ Crash Course: Data Oriented Design

preview_player
Показать описание
In this video we look at a simple example of data oriented design in C++!

Рекомендации по теме
Комментарии
Автор

Finally something about this topic that isn't a 1hr talk from some random conference. Thank you!

bronzekoala
Автор

Great and intuitive explanation! It would be better if the volume is greater.

koktszfung
Автор

A very concise presentation on DoD. Thank you!

mehtubbhai
Автор

How would the performance be if you just access just one “employee” and update v0-15. Wouldn’t OO be faster?

MyNameIssaSimon
Автор

An excellent explanation of the motivation for DOD. Thank you!

RupertBruce
Автор

hold on...
structures can house functions?
When was this a thing?
neither of my C++ professors in college informed me of this.
*Having an existential criss*

InfmousKidGames
Автор

as Humble java coder
i recognize 1:38 as bad programming practice
glad he is teaching people not to copy and paste their lines 100s of times
and instead to use lists/arrays and loops
i see people starting out doing this mistake rather then simplify and using good programming practices

Detective_Jones
Автор

Nice and simple explanation! I like it.

syrix
Автор

Good video.
That said it's more a demonstration of array-of-struct vs struct-of-array, which is only one of the many pattern of DOD (vs OOP for example).

e
Автор

Can someone help me to understand this:

If a cache line is 16 integers long, then why is it that an array of structs with 16 integers each has cache misses in between each struct but a struct of arrays with 16 integers each has hardly any cache misses between the arrays?

And also thank you for such a great video on this topic. Very concise and informative.

williamiiifarquhar
Автор

I can definitely see a lot of places where this is going to be useful. Mainly storing vertex data fields separately. Vertex Animation doesn't usually update much more than just the positions of vertices. Maybe normals, but that can have it's own update pass.

Oop is still better front-end for the user but for internal data structures this should be pretty easy to do.

noxagonal
Автор

Do "data oriented design" and "data oriented programming" are the same ??

miguelx
Автор

Although this is a good demo, it reminds me of a South Park episode about gnomes. But with a slight modification in this case: "1. ??? 2.Use SaO 3.Profit".
"Benchmarking SoA" video title would be a 100% descriptive in this case. But in no way it is a "Data-oriented Design". This video would have a lot more exclusive value if you showed at least a basic example of a real life problem. Becuase "if we had data stored in such a way to eliminate cache misses" is just a magic thinking. What about writing? What about sorting or filtering? What about concurrency and shared memory access? What about existing ways to abstract the data?
Don't get me wrong, this material and video is valuable (alghough not unique). But when people search for "DoD Design in practice", this video title is false-advertising.

sergeykolesnik
Автор

In 3:10. Why do you use auto &i instead of auto i. Isnt getting the pointer and incrementing it that way the same as getting the value and incrementing but with more steps?

MyNameIssaSimon
Автор

What's preventing a compiler from just translating an OO design into a DO design?
They already take advantage of stupid stuff like arrays being stepped thru backwards being faster on some machines.

androkon
Автор

I would like to argue that at 5:58 ArrayOfStructs had to allocate the memory first, but StructOfArrays could just reuse it. What's the performance like if you swap the order of iteration (Tha tis, run StructOfArrays first)?

patrikjankovics
Автор

Thanks! Say, does this work for C# too?

vladmrkrnev
Автор

as a former skeptic as of this video, i'd like to see that in a more robust application - or at least with more robust data and processing - to actually settle this discussion. looks promissing but i'm wondering if the complexity - or lack thereof - of this application skews the results towards dod. otherwise great video my dude.

mattzrsimon
Автор

Honestly, only measuring the worst case makes this look a little deceptive. I'd be more interested in a more representative case, like say an array of vec4 vs struct of arrays of x, y, z, and w components where you might use 2 or 3 (or all 4) for a calculation. Or what about a struct of mixed fields (you mentioned an "employee", so how about names and salaries and departments and schedules and other mixed types), vs splitting those fields into separate arrays.

You show the absolute worst case, but I think it would be more useful to show the typical case to better weight the cost in more realistic scenarios. In my own code, I tend toward an "object oriented" approach (which seems to mean different things to different people, so who knows how meaningful that term is), and thus I tend to have data that is used together in one struct. I avoid the "ball of mud" antipattern that dumps lots of unrelated data into one object.

When I've toyed with DoD for my code, I haven't tended to see performance improvements, no doubt because all the data was needed for the calculations I was doing (which is why they were in one object in the first place) while unrelated data was called out in separate objects and thus not polluting the cache line. So this leaves me wondering what real advantage DoD has for those who follow OO mantras like single responsibility and inversion of control which tend towards smaller focused objects with the exact data needed.

oracleoftroy
Автор

I'm kind of confused. I mean I get the whole idea but aren't vectors more like lists and not arrays? Because I thought that in lists one item points to the next one, so they're technically not 'next to' each other in memory. Or does C++ somehow optimize this? Am I missing something?

BExploit