News for hackers. Stuff that matters.
Re:Bulk Data Structures C++ by plopz on Tuesday August 20, 2019 @05:31PM (#20752417)
Doesn't the memory layout actually matter for cache locality? So you would still need to be able to have both memory layouts for performance.
Re:Bulk Data Structures C++ by std_throwaway on Tuesday August 20, 2019 @05:37PM (#20752478)
Cache locality is kind of the whole point of it. Some algorithms benefit hugely if you choose a specific layout.

Other algorithms do some kind of random access to a few fields only and they don't benefit at all. Those algorithms can make up 90% of your code but only account for 10% of the computation. Therefore it would be easier to have your data look like a AoS in 90% of your code but actually be stored as a SoA to gain the speed in 90% of the computation.

Re:Bulk Data Structures C++ by hermitdev on Tuesday August 20, 2019 @10:01PM (#20754018)
Most definitely.

If, for example you've got a vector of structs (which is a basic tabular store, that is row major). Depending on the operations you're performing, you may see huge performance benefits from instead using a column oriented data structure. Especially with very large datasets. A large part of this because of cache locality and prefetch.

I see this in finance often. For querying large, slowly changing datasets, column store RDBMS destroy traditional row oriented stores. Column stores can be colloquially an order of magnitude faster for some operations, such as computing aggregates grouped by a date (but theyre significantly much slower for inserts and even more so for updates).

As usual, when it comes down to optimizations, depends on the use case, and experiment and measure, measure, measure.

Also, another big caveate is that it can change arbitrarily with different hardware or even OS revisions.

Edit: spelling