Timing and Sizes

A break from process. I find this table to be quite useful for comparison and as a rule-of-thumb reference.

Timing
0.5 ns Fetch from L1 Cache
1   ns Execute typical instruction
5   ns Branch misprediction
7   ns Fetch from L2 Cache
25  ns Mutex lock/unlock
100 ns Fetch from RAM
250 ns System call overhead*
500 ns Context switch**
20  us Send 2KB on network
50  us Fetch from SSD
250 us Read 1MB from RAM
500 us Round trip packet send in same data center
5   ms Fetch from HDD
20  ms Read 1MB sequentially from HDD
150 ms Round trip packet to Europe

* Linux has some system calls cached, e.g. getpid which take ~5ns.
** Context switch has many dependencies and may take 10x longer. Switching to a new process is slightly more expensive. A new process causes TLB flush and thus L1 Cache misses (L1 cache stores virtual addresses).

Sizes
64  B Cache Line
4   K RAM Page Size
64  K L1 Cache
512 K L2 Cache
8   M L3 Cache
8   G RAM
1   T HDD

Leave a Reply

Your email address will not be published. Required fields are marked *