About Me

I am a computer programmer. I do programming professionally and for a laugh.

Technical stuff on programming, java, DSLs, etc...

Monday 1 March 2021

Computer latency scaled

We all love to talk about Architecture - micro services, message passing, event streams, sow, etc. It all boils down to the below. 

Can you fit your work in the cache or do you regularly fall off to the main memory? What is the penalty for calling another service? Or can it be faster than accessing the disk? You should be able to talk about these roughly for your application. 

If you are into computers, best to know this stuff - 

p.s. Also, this is why you should use an ArrayList over a LinkedList most days


System Event Actual Latency Scaled Latency
One CPU cycle 0.4 ns 1 s
Level 1 cache access (8 KB to 128 KB) - 128 KB 0.9 ns 2 s
Level 2 cache access (256KB to 8MB) - 512 KB 2.8 ns 7 s
Level 3 cache access ( 4MB to 50MB) - 3 MB 28 ns 1 min
Main memory access (DDR DIMM) ~100 ns 4 min
Intel Optane memory access <10 μs 7 hrs
NVMe SSD I/O ~25 μs 17 hrs
SSD I/O 50–150 μs 1.5–4 days
Rotational disk I/O 1–10 ms 1–9 months
Internet call: San Francisco to New York City 65 ms 5 years
Internet call: San Francisco to Hong Kong 141 ms 11 years

(don't worry too much about the numbers not 100% matching with the above - different times, different architectures etc..)

execute typical instruction 1 ns 1 ns
fetch from L1 cache memory 0.5 ns 0.5 ns
branch misprediction 5 ns 5 ns
fetch from L2 cache memory 7 ns 7 ns
Mutex lock/unlock 25 ns 25 ns
fetch from main memory 100 ns 100 ns
send 2K bytes over 1Gbps network 20,000 ns 20 μs
read 1MB sequentially from memory 250,000 ns 250 μs
fetch from new disk location (seek) 8,000,000 ns 8 ms
read 1MB sequentially from disk 20,000,000 ns 20 ms
send packet US to Europe and back 150,000,000 ns 150 ms

No comments:

Post a Comment

Followers