⚡ Latency Numbers Every Programmer Should Know
Understanding the relative speed of different operations in computing is crucial for writing efficient code. Below is a list of key latency numbers, from CPU cache accesses to network round trips.
🏎️ CPU & Memory Operations
Operation |
Time |
Emoji Representation |
🏷️ L1 cache reference
|
0.5 ns |
🔥 Ultra-fast |
🔀 Branch mispredict
|
5 ns |
🔄 Slight penalty |
🏷️ L2 cache reference
|
7 ns |
🚀 Fast |
🔐 Mutex lock/unlock
|
100 ns |
🔒 Synchronization cost |
🎯 L3 cache reference
|
30 ns |
🎯 Moderate speed |
🧠 Main memory reference
|
100 ns |
📦 Memory access |
📡 Data Compression & Transfer
Operation |
Time |
Emoji Representation |
📦 Compress 1K bytes with Zippy
|
10 µs |
🗜️ Compression cost |
🌐 Send 2K bytes over 1 Gbps network
|
20 µs |
📡 Network transfer |
📚 Read 1 MB sequentially from memory
|
250 µs |
📖 RAM read |
🏢 Datacenter & Disk Operations
Operation |
Time |
Emoji Representation |
🏢 Round trip within the same datacenter
|
500 µs |
🔄 Local network |
💽 Disk seek (random access on HDD)
|
10 ms |
🛑 Expensive |
🌍 Read 1 MB sequentially from the network
|
10 ms |
🌐 Internet speed |
💾 Read 1 MB sequentially from SSD
|
1 ms |
⚡ Fast storage |
📀 Read 1 MB sequentially from HDD
|
30 ms |
🐢 Slow disk access |
🌎 Network & Intercontinental Transfers
Operation |
Time |
Emoji Representation |
🚀 Packet transmission across the US
|
50 ms |
✈️ Coast-to-coast |
🌍 Packet round-trip US → Europe
|
100 ms |
🌐 Intercontinental |
🚀 Packet round-trip CA → Netherlands → CA
|
150 ms |
🛰️ Global transfer |
🚀 Packet one-way Earth → Mars (at closest distance)
|
4-24 min |
🛸 Interplanetary delay |
🔥 Key Takeaways
-
Nanoseconds (ns) ⚡: CPU operations, cache, and memory references.
-
Microseconds (µs) ⏳: Network and data compression operations.
-
Milliseconds (ms) 🐢: Disk access, network round trips.
-
Minutes 🚀: Deep-space communication delays.
🚀 If you found this helpful, follow me for more programming insights!
Top comments (0)