Skip to content

Instantly share code, notes, and snippets.

@wzulfikar
Last active January 12, 2023 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wzulfikar/4504830ebd8bae884b84d7f1b73a434a to your computer and use it in GitHub Desktop.
Save wzulfikar/4504830ebd8bae884b84d7f1b73a434a to your computer and use it in GitHub Desktop.

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns  =          14x L1
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns  =          20x L2
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns  = 250 µs
Round trip within same datacenter ...... 500,000 ns  = 0.5 ms = 5000x memory reference
Read 1 MB sequentially from SSD* ..... 1,000,000 ns  =   1 ms
Disk seek ........................... 10,000,000 ns  =  10 ms = 20x datacenter roundtrip
Display one frame in 60 FPS setting.. 16,000,000 ns  =  16 ms
Read 1 MB sequentially from disk .... 20,000,000 ns  =  20 ms
Blink of an eye..................... 100,000,000 ns  = 100 ms (avg duration, based on wikipedia.org/wiki/Blinking)
Send packet CA->Netherlands->CA .... 150,000,000 ns  = 150 ms (0.15 s)
(US-EU roundtrip)
Light to reach the moon............2,510,000,000 ns  = 2,510 ms = 2.51 s

Assuming ~1GB/sec SSD. Data by Jeff Dean.

▲▼▲

From Nielsen Norman Group on usability:

  • 100ms (0.1s): the limit for having the user feel that the system is reacting instantaneously (no special feedback is necessary except to display the result)
  • 1 second: the limit for the user's flow of thought to stay uninterrupted, even though the user will notice the delay. Normally, no special feedback is necessary during delays of more than 0.1 but less than 1.0 second, but the user does lose the feeling of operating directly on the data.
  • 10 second: the limit for keeping the user's attention focused on the dialogue

Ref: https://www.nngroup.com/articles/response-times-3-important-limits/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment