AoS vs. SoA: Cache Line Waste up to 200%

When using an Array of Structures (AoS) and only accessing a single member, a cache line can load the entire structure, wasting up to 200% of memory for small data types (e.g., 4-byte integer in a 64-bit system with 8-byte pointers), where only a fraction is used. Structure of Arrays (SoA) mitigates this by grouping similar fields, improving spatial locality.

Sources

Open the full topic