by dragontamer · 4y ago · 0 comments
Its not so much that "structure packing" is dead, as much as a wide variety of techniques have been developed above-and-beyond just simply structure packing. There's many ways to skin a cat these days, and packing your structures more intelligently is just one possible data optimization.
If you have some giant bloated struct and you only care about one or two fields at a time, that's one thing. But if you have a well-aligned, correctly packed struct and you're processing all its data, it's total nonsense to break that up.
But empirically speaking, it seems like SOA / AOS is the easiest "beginner topic" to get high performance-programmers thinking about memory-layout issues.
Maybe in the 90s or 00s, it was more popular to think about struct layouts, alignment issues and the like. But today, SOA is popular because RAM has gotten less... random... and more sequential.
I think its the changing nature of 90s era computers (RAM behaving more random-accessy) vs the nature of 10s era computers (RAM behaving more sequential-accessy)
--------
Its not like the 90s techniques don't work anymore. But the 10s technique of "structure of arrays" and then iterating for-loops over your data works better with prefetchers, multiple-cache hierarchies, and other tidbits that have made RAM more sequential than ever before.
Hopefully programmers continue to study the techniques and understand what is going on under-the-hood, instead of cargo-culting the pattern. Alas, we all know that cargo-culting works in the short term and is easier to do than actually learning the underlying machine!
Also of course AoS has fixed fields, while SoA has dynamic fields.