This is an outstanding talk by Scott Meyers on hardware and CPU caches ..
YOUR CODE ISN'T SLOW BECAUSE OF YOUR ALGORITHM, IT'S SLOW BECAUSE OF A TINY CHUNK OF MEMORY YOU'VE NEVER ONCE THOUGHT ABOUT AND THIS MAN PROVES IT WITH TWO PROGRAMS THAT DO THE EXACT SAME WORK, WHERE ONE IS MASSIVELY FASTER
76 minutes from Scott Meyers -- the C++ authority whose "Effective C++" books a whole generation of engineers learned from.
-> His point: the CPU is not waiting on math. It's waiting on memory. And it's starving far more often than you think.
The cache is a scrap of ultra-fast memory near the core. Hit it and you fly. Miss it and the whole chip stalls, doing nothing, for what feels like forever.
He shows the same loop, same data, just walked in a different order. One layout stays in cache. The other keeps missing. The gap is not small -- it's brutal.
The kicker: your language, your fancy abstractions, none of it hides this. A "clean" data structure that scatters memory quietly wastes most of your machine.
And it's the AI era's hidden tax too. Everyone rents oceans of compute, then leaves most of it stalled on cache misses nobody profiles.
You thought fast code was about picking the right algorithm. This is the man showing it's really about how your data sits in memory.
Save this. You'll never lay out a struct the same way ↓