Cache Miss Penalties: Thousands of CPU Cycles Lost to Slower Memory

A miss in the ultra-fast L1 cache that hits L2 can cost 3-15 CPU cycles, while an L2 miss reaching L3 may incur 10-40 cycles. If data isn't in any cache and must be fetched from main memory (RAM), the penalty can exceed hundreds of CPU cycles, potentially stalling the processor for hundreds of nanoseconds.

The top 3

  1. Memory Hierarchy Latency: L1 Cache vs. DRAM Speed Gap: Accessing L1 cache takes approximately 1 nanosecond (ns), while main memory (DRAM) can take 50-100 ns, making DRAM access 50 to 200 times slower and costing hundreds of CPU cycles.
  2. Top 3 CPU Cache Optimizations: Hardware's Best Moves: CPUs reduce cache miss penalties through hardware prefetching (proactively loading data), larger cache lines (e.g., 64 bytes) to exploit spatial locality, and sophisticated replacement policies like LRU variants to keep frequently used data.
  3. Three Types of Cache Misses: Causes & Penalties: Cache misses fall into three categories: compulsory (first access), capacity (cache too small for working set), and conflict (data mapped to same cache location), each leading to substantial performance penalties.

Sources

Open the full topic