Hacker News new | ask | show | jobs
by 10000truths 550 days ago
Access patterns matter, but just as important is to have less stuff to access. That's why arrays-of-structs are considered cache friendly - columnar data layouts open the door to optimizations that significantly reduce memory footprint. You no longer waste memory with struct padding. Boolean fields can become bitsets. Enums can be bit-packed. Often-null optional fields can become sparse maps. 8-byte pointers can become narrower-sized indices into object pools.
1 comments

> “That's why arrays-of-structs are considered cache friendly”

Sounds like you mean structs-of-arrays?

Oops, brainfart on my part. Unfortunately, the edit window has passed.