System Latencies at a Glance
Visualizing the vast difference in time scales between various system operations. Understanding these numbers is crucial for system design and performance optimization.
The Numbers
Approximate timing for various operations on a typical modern system.
| Key / Code | Description |
|---|---|
| L1 Cache Reference | 0.5 ns |
| Branch Mispredict | 5 ns |
| L2 Cache Reference | 7 ns |
| Mutex Lock/Unlock | 25 ns |
| Main Memory Reference | 100 ns |
| Compress 1K Bytes with Zippy | 3,000 ns (3 µs) |
| Send 2K Bytes over 1 Gbps Network | 20,000 ns (20 µs) |
| Read 1 MB sequentially from Memory | 250,000 ns (250 µs) |
| Round Trip within same Data Center | 500,000 ns (500 µs) |
| Disk Seek | 10,000,000 ns (10 ms) |
| Read 1 MB sequentially from Network | 10,000,000 ns (10 ms) |
| Read 1 MB sequentially from Disk | 20,000,000 ns (20 ms) |
| Send Packet CA -> Netherlands -> CA | 150,000,000 ns (150 ms) |
Human Scale Analogy
If 1 CPU cycle (0.3 ns) was equal to 1 second:
| Key / Code | Description |
|---|---|
| L1 Cache Access | 1.5 seconds |
| Main Memory Access | 6 minutes |
| Solid State Drive I/O | 2 - 6 days |
| Rotational Disk I/O | 1 - 12 months |
| Internet: SF to NYC | 4 years |
| Internet: SF to UK | 8 years |
| OS Virtualization Reboot | 423 years |
Takeaways
1. Accessing memory is fast, but reading from disk is incredibly slow by comparison. 2. Network calls within a data center are expensive compared to local memory, but cheap compared to cross-continent calls. 3. Avoid disk seeks whenever possible.
Knowledge is power.