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 w/ cheap algorithm | 3,000 ns |
Send 2K bytes over 1 Gbps network | 20,000 ns |
Read 1 MB sequentially from memory | 250,000 ns |
Round trip within same datacenter | 500,000 ns |
Disk seek | 10,000,000 ns |
Read 1 MB sequentially from disk | 20,000,000 ns |
Send packet CA->Netherlands->CA | 150,000,000 ns |
For more details: Agner's Software optimization resources.
7 comments:
really like the list. dont know if every programmer needs to knowj all these numbers... just how to derive them is all that is needed. useful though.
also: log_2(1000) = ~10, log_2(1000000) = ~20
Wouldn't disk seek be changed for SSDs?
In the US, a Google search end to end is about 200,000ns. To your desktop.
Argh, my apologies. 200,000,000ns for a Google search. 200ms.
Obviously this is all hardware dependant, but should give a rough idea of the relative costs.
Consider a line graph, with latency of access on the Y-axis, and something like "problem size" on the X axis.
If Moore's Law ever had meaning, it tracked how fast the left end of the curve has fallen over time, but I think you'd come to different answers if you looked at different points on the curve.
Post a Comment