Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers Simplified (~2012)
---------------------------------- log2 log10
L1 cache reference 0 0 ~ 1 ns
Branch mispredict 3 1
L2 cache reference 4 1
Mutex lock/unlock 6 2
Main memory reference 8 2
Compress 1K bytes with Zippy 13 4
Send 1K bytes over 1 Gbps network 14 4
Read 4K randomly from SSD* 18 5
Read 1 MB sequentially from memory 19 6
Round trip within same datacenter 20 6
Read 1 MB sequentially from SSD* 21 6
Disk seek 24 7
Read 1 MB sequentially from disk 25 8
Send packet CA->Netherlands->CA 28 9
Notes
-----
The log2 and log10 columns have logarithm computations (rounded to an integer power)
relative to the first item on the list (L1 cache reference). I find that the exact
numbers are not terribly important. It is much simpler to reason about relative
dimensions in this format---simply take two elements in a column and subtract
them. For example, using the log10 column, "Read 1 MB sequentially from memory"
is about 1000000 slower than "L1 cache reference" and 10000 slower than
"Main memory reference". For very rough back-of-the-envelope computations, I often
use 2^10 ~ 10^3 and 2^3 ~ 10^1, e.g., "Send 1K bytes over 1 Gbps network" is about
16000 slower than "L1 cache reference". The logarithms were computed from the
numbers found in https://gist.github.com/jboner/2841832.
@artkpv

This comment has been minimized.

Copy link

artkpv commented Jan 30, 2019

Not sure about log2 here. Rounded up at https://gist.github.com/artkpv/dce2870a8241ff2c0164337422566fc5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.