The full picture
🎬 The memory hierarchy & why locality is everything
1 / 5Fast memory is expensive and tiny; big memory is slow. So machines stack them: registers → L1/L2/L3 caches (SRAM) → main memory (DRAM) → SSD. Each level is ~10× slower and ~1000× bigger than the one above.
- Use the ratios, not the absolutes: DRAM is ~100× L1; a miss is ~300+ potential instructions; SSD is ~1000× DRAM. Back-of-envelope: 'this hash join walks 10M random pointers → 10M × 100ns = 1 second of pure memory stalls' — that estimate, said aloud, is the senior skill.
- Why hierarchy instead of one fast memory: SRAM cost/density and the speed-of-light-ish reality that bigger = farther = slower. It's caching all the way down — CDN→Redis→page cache→L3→L1 are one design pattern at seven scales.
- The memory wall: CPU speed grew ~50%/yr for decades, DRAM latency barely moved — the entire modern core (OoO, prefetch, SMT, giant caches) is a coping mechanism. GC theory, columnar databases and cache-oblivious algorithms are all downstream of this one divergence.
- Numbers date-stamp: quote them as orders of magnitude ('L1 ~1ns, DRAM ~100ns, NVMe ~100µs') and you're immune to hardware-generation nitpicks.