{"id":50624,"date":"2026-01-05T17:18:07","date_gmt":"2026-01-05T22:18:07","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=50624"},"modified":"2026-01-07T15:10:57","modified_gmt":"2026-01-07T20:10:57","slug":"latency-numbers-every-programmer-should-know","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2026\/01\/05\/latency-numbers-every-programmer-should-know\/","title":{"rendered":"Latency Numbers Every Programmer Should Know"},"content":{"rendered":"<p><a href=\"https:\/\/gist.github.com\/jboner\/2841832\">Jonas Bon&eacute;r<\/a> (based on work by Peter Norvig and Jeff Dean from 2012):<\/p>\n<blockquote cite=\"https:\/\/gist.github.com\/jboner\/2841832\">\n<pre>\nL1 cache reference                           0.5 ns\nBranch mispredict                            5   ns\nL2 cache reference                           7   ns                      14x L1 cache\nMutex lock\/unlock                           25   ns\nMain memory reference                      100   ns                      20x L2 cache, 200x L1 cache\nCompress 1K bytes with Zippy             3,000   ns        3 us\nSend 1K bytes over 1 Gbps network       10,000   ns       10 us\nRead 4K randomly from SSD*             150,000   ns      150 us          ~1GB\/sec SSD\nRead 1 MB sequentially from memory     250,000   ns      250 us\nRound trip within same datacenter      500,000   ns      500 us\nRead 1 MB sequentially from SSD*     1,000,000   ns    1,000 us    1 ms  ~1GB\/sec SSD, 4X memory\nDisk seek                           10,000,000   ns   10,000 us   10 ms  20x datacenter roundtrip\nRead 1 MB sequentially from disk    20,000,000   ns   20,000 us   20 ms  80x memory, 20X SSD\nSend packet CA-&#x3E;Netherlands-&#x3E;CA    150,000,000   ns  150,000 us  150 ms<\/pre>\n<\/blockquote>\n\n<p><a href=\"https:\/\/colin-scott.github.io\/personal_website\/research\/interactive_latency.html\">Colin Scott<\/a> has a page that helps visualize how these types of numbers have changed over time (<a href=\"https:\/\/news.ycombinator.com\/item?id=30546995\">Hacker News<\/a>).<\/p>\n\n<p><a href=\"https:\/\/irreal.org\/blog\/?p=12870\">Jon Snader<\/a>:<\/p>\n<blockquote cite=\"https:\/\/irreal.org\/blog\/?p=12870\">\n<p>Mohammad Zeya Ahmad has <a href=\"https:\/\/medium.com\/@mohammadzeyaahmad\/latency-numbers-every-programmer-should-know-87301800c605\">an informative post<\/a> [<a href=\"https:\/\/web.archive.org\/web\/20250329095853\/https:\/\/medium.com\/@mohammadzeyaahmad\/latency-numbers-every-programmer-should-know-87301800c605\">archive<\/a>] that answers that question. He has a list of how much time various common operations take. That&rsquo;s interesting but what make his list stand out is that he draws conclusions from his results.\n<\/p>\n<p>\nFor example, SSDs are about 30 times faster than HDDs so if you have a high performance disk-based task, it makes sense to use SSDs. Of course, there are reasons to prefer HDDs but if performance is your controlling metric, SSDs are probably your best choice.\n<\/p>\n<p>\nFor each group of comparable metrics, Ahmad offers an actionable suggestion. Those groups range from CPU versus Cache and Memory speeds to network transfer times.<\/p>\n<\/blockquote>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2026\/01\/05\/python-numbers-every-programmer-should-know\/\">Python Numbers Every Programmer Should Know<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2018\/05\/10\/c-is-not-a-low-level-language\/\">C Is Not a Low-level Language<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2022\/01\/03\/squeezing-the-most-out-of-bluetooth\/\">Squeezing the Most Out of Bluetooth<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2016\/04\/21\/performance-comparisons-of-common-operations-2016-edition\/\">Performance Comparisons of Common Operations, 2016 Edition<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2012\/05\/21\/transatlantic-ping\/\">Transatlantic Ping Faster Than Sending a Pixel to the Screen<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Jonas Bon&eacute;r (based on work by Peter Norvig and Jeff Dean from 2012): L1 cache reference 0.5 ns Branch mispredict 5 ns L2 cache reference 7 ns 14x L1 cache Mutex lock\/unlock 25 ns Main memory reference 100 ns 20x L2 cache, 200x L1 cache Compress 1K bytes with Zippy 3,000 ns 3 us Send [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2026-01-05T22:18:10Z","apple_news_api_id":"38d8e0b8-b157-49b1-bbee-cf9cfe29f394","apple_news_api_modified_at":"2026-01-07T20:11:01Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAQ==","apple_news_api_share_url":"https:\/\/apple.news\/AONjguLFXSbG77s-c_inzlA","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[259,571,138,260,71,183,174],"class_list":["post-50624","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-math","tag-memory-management","tag-optimization","tag-processors","tag-programming","tag-ssd","tag-storage"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/50624","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=50624"}],"version-history":[{"count":3,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/50624\/revisions"}],"predecessor-version":[{"id":50639,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/50624\/revisions\/50639"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=50624"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=50624"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=50624"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}