Skip to content

Instantly share code, notes, and snippets.

@BlackHC
Last active August 14, 2024 09:25
Show Gist options
  • Save BlackHC/2d0a3a21542b524a7cf2f8eac977481e to your computer and use it in GitHub Desktop.
Save BlackHC/2d0a3a21542b524a7cf2f8eac977481e to your computer and use it in GitHub Desktop.
Numbers everyone (programmer) should know (2023)
Latency Comparison Numbers (~2023)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Snappy 3,000 ns 3 µs
Read 1 MB sequentially from memory 20,000 ns 20 µs ~50GB/sec DDR5
Read 1 MB sequentially from NVMe 100,000 ns 100 µs ~10GB/sec NVMe, 5x memory
Round trip within same datacenter 500,000 ns 500 µs
Read 1 MB sequentially from SSD 2,000,000 ns 2,000 µs 2 ms ~0.5GB/sec SSD, 100x memory, 20x NVMe
Read 1 MB sequentially from HDD 6,000,000 ns 6,000 µs 6 ms ~150MB/sec 300x memory, 60x NVMe, 3x SSD
Send 1 MB over 1 Gbps network 10,000,000 ns 10,000 µs 10 ms
Disk seek 10,000,000 ns 10,000 µs 10 ms 20x datacenter roundtrip
Send packet CA->Netherlands->CA 150,000,000 ns 150,000 µs 150 ms
Notes
-----
1 ns = 10^-9 seconds
1 µs = 10^-6 seconds = 1,000 ns
1 ms = 10^-3 seconds = 1,000 µs = 1,000,000 ns
| Operation | Latency (ns) | Latency (µs/ms) | Comparison |
| ---------------------------------- | ------------ | ------------------- | ---------------------------------------- |
| L1 cache reference | 0.5 | | |
| Branch mispredict | 5 | | |
| L2 cache reference | 7 | | 14x L1 cache |
| Mutex lock/unlock | 25 | | |
| Main memory reference | 100 | | 14x L2 cache, 200x L1 cache |
| Compress 1K bytes with Snappy | 3,000 | 3 µs | |
| Read 1 MB sequentially from memory | 20,000 | 20 µs | ~50GB/sec DDR5 |
| Read 1 MB sequentially from NVMe | 100,000 | 100 µs | ~10GB/sec NVMe, 5x memory |
| Round trip within same datacenter | 500,000 | 500 µs | |
| Read 1 MB sequentially from SSD | 2,000,000 | 2,000 µs (2 ms) | ~0.5GB/sec SSD, 100x memory, 20x NVMe |
| Read 1 MB sequentially from HDD | 6,000,000 | 6,000 µs (6 ms) | ~150MB/sec 300x memory, 60x NVMe, 3x SSD |
| Send 1 MB over 1 Gbps network | 10,000,000 | 10,000 µs (10 ms) | |
| Disk seek | 10,000,000 | 10,000 µs (10 ms) | 20x datacenter roundtrip |
| Send packet CA->Netherlands->CA | 150,000,000 | 150,000 µs (150 ms) | |
**Notes**
1 ns = 10^-9 seconds
1 µs = 10^-6 seconds = 1,000 ns
1 ms = 10^-3 seconds = 1,000 µs = 1,000,000 ns
What is the latency for an L1 cache reference?
?
The latency for an L1 cache reference is 0.5 ns.
What is the latency for a branch mispredict?
?
The latency for a branch mispredict is 5 ns.
What is the latency for an L2 cache reference and how does it compare to an L1 cache reference?
?
The latency for an L2 cache reference is 7 ns, which is approximately 14 times the latency of an L1 cache reference.
What is the latency for a mutex lock/unlock?
?
The latency for a mutex lock/unlock is 25 ns.
What is the latency for a main memory reference and how does it compare to L1 and L2 cache references?
?
The latency for a main memory reference is 100 ns, which is approximately 200 times the latency of an L1 cache reference and 14 times the latency of an L2 cache reference.
What is the latency to compress 1K bytes with Snappy?
?
The latency to compress 1K bytes with Snappy is 3,000 ns or 3 µs.
What is the latency to read 1 MB sequentially from memory and what is the equivalent speed?
?
The latency to read 1 MB sequentially from memory is 20,000 ns or 20 µs, which is equivalent to a speed of about 50 GB/sec for DDR5 memory.
What is the latency to read 1 MB sequentially from an NVMe disk and how does it compare to memory?
?
The latency to read 1 MB sequentially from an NVMe disk is 100,000 ns or 100 µs, which is approximately 5 times the latency of reading from memory and equivalent to a speed of about 10 GB/sec for NVMe.
What is the latency for a round trip within the same datacenter?
?
The latency for a round trip within the same datacenter is 500,000 ns or 500 µs.
What is the latency to read 1 MB sequentially from an SSD disk and how does it compare to memory and NVMe?
?
The latency to read 1 MB sequentially from an SSD disk is 2,000,000 ns or 2,000 µs (2 ms), which is approximately 100 times the latency of reading from memory, 20 times the latency of reading from an NVMe disk, and equivalent to a speed of about 0.5 GB/sec for SSD.
What is the latency to read 1 MB sequentially from an HDD disk and how does it compare to memory, NVMe, and SSD?
?
The latency to read 1 MB sequentially from an HDD disk is 6,000,000 ns or 6,000 µs (6 ms), which is approximately 300 times the latency of reading from memory, 60 times the latency of reading from an NVMe disk, 3 times the latency of reading from an SSD, and equivalent to a speed of about 150 MB/sec.
What is the latency to send 1 MB over a 1 Gbps network?
?
The latency to send 1 MB over a 1 Gbps network is 10,000,000 ns or 10,000 µs (10 ms).
What is the latency for a disk seek and how does it compare to a round trip within the same datacenter?
?
The latency for a disk seek is 10,000,000 ns or 10,000 µs (10 ms), which is approximately 20 times the latency of a round trip within the same datacenter.
What is the latency for a round trip for packet data from USA to Europe and back?
?
The latency for a round trip for packet data from USA to Europe and back is 150,000,000 ns or 150,000 µs (150 ms).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment