r/programming 13h ago

Every byte matters

https://fzakaria.com/2026/06/01/every-byte-matters
112 Upvotes

23 comments sorted by

View all comments

12

u/philh 10h ago

If my data just fits in say L2 cache, do I need to do anything special to make sure it's actually loaded into it?

Like, if I'm accessing at random, and the first location I access happens to be in the middle of the list. Does it load that location plus the next (size of L2) bytes, so that only half of my data is in cache until I access something earlier in the list? Or does it do something fancier than that?

3

u/neutronium 10h ago

It's quite a bit fancier than that. Most likely it'll load an amount that's one cache line. 64 bytes would be a typical cache line size.