Post

Memory - Memory Latency

Memory - Memory Latency

🧠 Memory Latency Hierarchy β€” Why Caches Matter

Latency

This table compares hardware access latency with a scaled real-world time analogy
to illustrate how dramatically access time increases across memory/storage layers.


1️⃣ Memory Access Latency Comparison

System EventActual LatencyScaled Human-Time Analogy
CPU Register / 1 CPU cycle~0.4 ns1 second
L1 Cache Access~0.9 ns2 seconds
L2 Cache Access~2.8 ns7 seconds
L3 Cache Access~28 ns1 minute
Main Memory (RAM)~100 ns4 minutes
Optane / Persistent Memory~10 Β΅s7 hours
NVMe SSD I/O~25 Β΅s17 hours
SSD I/O~50–150 Β΅s1.5–4 days
HDD (Rotational Disk)~1–10 ms1–9 months
Internet (SF β†’ NYC)~65 ms5 years
Internet (SF β†’ Hong Kong)~141 ms11 years

2️⃣ Key Insight β€” Latency Grows Explosively

Each step down the hierarchy is orders of magnitude slower:

  • Register β†’ Cache: ~2Γ— slower
  • Cache β†’ RAM: ~100Γ— slower
  • RAM β†’ SSD: ~1,000Γ— slower
  • SSD β†’ HDD: ~10,000Γ— slower
  • Disk β†’ Internet: Millions of times slower

This is why memory locality and caching dominate real-world performance.


3️⃣ Why Data Is Accessed in This Order

(L1 β†’ L2 β†’ L3 β†’ RAM β†’ Storage)

βœ… Reason 1 β€” Speed vs Cost Tradeoff

LayerSpeedCostCapacity
RegistersFastestVery expensiveTiny
L1 CacheVery fastExpensiveSmall
L2 CacheFastExpensiveMedium
L3 CacheSlowerCheaperLarger
RAMMuch slowerAffordableLarge
StorageSlowestCheapestHuge

We cannot build large memory entirely from ultra-fast storage β€” too expensive and power-hungry.


βœ… Reason 2 β€” Locality of Reference

Locality

Programs tend to:

  • Reuse recent data (temporal locality)
  • Access nearby memory (spatial locality)

So CPU checks fast memory first, because it is likely already there.


βœ… Reason 3 β€” Avoiding Massive Stall Time

If CPU accessed RAM every time:

  • Pipeline stalls
  • CPU idle time skyrockets
  • Performance collapses

Caches hide RAM latency so the CPU stays busy.


βœ… Reason 4 β€” Hierarchical Filtering Model

Think of memory like a search chain:

This post is licensed under CC BY 4.0 by the author.