Work in progress: 181,232 of 181,233 sites checked so far, more every week · updated 2 Nov 2026Missing a blog? Tell us

Top all-time · #4355

T

Tsuna's blog

Personal blog · blog.tsunanet.netprogrammingsystems

Tsuna's blog is a personal blog at blog.tsunanet.net about programming and systems. Since 2010, 18 different Hacker News readers have linked it 19 times, most often “How long does it take to make a context switch? (2010)”. The last post was in 2023, but the archive is still widely read.

Visit the blog
19mentions?
18HN people?
2010–2021first – last linked?
Links on Hacker News per year · peak 5 in 2017

Too few sampled comments (11) to say how often HN recommends it.?

Why HN links it

Commenters repeatedly cite one 2010 post measuring the cost of a context switch on Linux, about 30µs, in discussions of threads, syscalls and caches. It is the most-linked reference on that topic here.

Summarised by Claude from a sample of 11 HN comments that link here. Each comment is marked recommending, critical or neutral (citing without judging); how this works.

In code we trust.

Most-linked posts?

  1. How long does it take to make a context switch? (2010)
    11 people · 11 mentions · first linked 2010-11-27
  2. /2010/11/how-long-does-it-take-to-make-context.html
    3 people · 3 mentions · first linked 2019-07-03
  3. Perforce killed my productivity again
    2 people · 2 mentions · first linked 2012-11-12

What Hacker News says?

  1. If you read the article linked to in the article I linked to above (which is fairly out of date, from 2010): https://blog.tsunanet.net/2010/11/how-long-does-it-take-to-m... you will find that on Linux a context switch takes about 30 usec. More recent measurements that take account of the effect of the TLB flush put the range at 10-300usec. That means that in 2010, on Linux , you could reasonably expect to do at leas…

    Comment linking /2010/11/how-long-does-it-take-to-make-context.html

    on “Bespoke Synth 1.0 – open-source software modular synthesizer”
  2. Submitted How long does it take to make a context switch? (2010) as a story · 87 points

    HN discussion
  3. The syscall overhead isn't the problem, that's dirt cheap as you say. The problem is the context-switch overhead. Calling into the OS flushes a lot of data and instructions from the cache, and that lost performance after returning can easily add up to around 30µs.[1] [1] http://blog.tsunanet.net/2010/11/how-long-does-it-take-to-ma...

    Comment linking /2010/11/how-long-does-it-take-to-make-context.html

    on “Non-volatile Storage: CPUs no longer more performant than I/O devices”
  4. Submitted How long does it take to make a context switch? as a story · 13 points

    HN discussion
  5. I heard that, especially with spectre, most of the cost of context switching comes from messing up your caches + TLB ( https://blog.tsunanet.net/2010/11/how-long-does-it-take-to-m... ). There's a graph on Dan Luu's blog about how it takes 14,000 cycles to get back to full performance after a syscall: https://danluu.com/images/new-cpu-features/flexsc_ipc_recove... .

    Comment linking /2010/11/how-long-does-it-take-to-make-context.html

    on “Ways of Implementing a System Call”
  6. Submitted Perforce killed my productivity again as a story · 5 points

    HN discussion
  7. It's a bit dated, but here's a reference: https://blog.tsunanet.net/2010/11/how-long-does-it-take-to-m...

    Comment linking /2010/11/how-long-does-it-take-to-make-context.html

    on “Why Continuations Are Coming to Java”
  8. Submitted Ext4 2x faster than XFS? as a story · 3 points

    HN discussion
  9. I can't explain completely, but check out http://blog.tsunanet.net/2010/11/how-long-does-it-take-to-ma... . Relatively speaking, I don't think context switching is _that_ expensive compared to other areas you can focus on like doing smarter memory management. I don't know exactly what they mean by threads having heavy memory overhead, but possibly they mean cache interference mentioned in that link? I'd be curious i…

    Comment linking /2010/11/how-long-does-it-take-to-make-context.html

    on “Futures for C++11 at Facebook”
  10. Submitted How long does it take to make a context switch? as a story · 2 points

    HN discussion
  11. There is nothing fundamentally new described in the blog post, although pinning threads to core is almost never the default operation mode (though many popular servers expose an option for turning this one). As someone else stated in another post, SO_REUSEPORT and accept4() is best, all things considered, way to accept connections across multiple threads. Again, most modern servers support this by default, if suppor…

    Comment linking /2010/11/how-long-does-it-take-to-make-context.html

    on “Fast Servers”
  12. Submitted Java IO: slowest readLine ever as a story · 1 points

    HN discussion
  13. > Context switches are really fast on modern x86. Not context switching is even faster. How fast is really fast, how modern is modern? some results from 2010 [1] show at least 1000 nanoseconds per context switch (even with optimizations for the kernel switching between threads of the same process). That's not that slow, but it is a lot of time you could be doing something else. [1] http://blog.tsunanet.net/2010/11/h…

    Comment linking /2010/11/how-long-does-it-take-to-make-context.html

    on “Fix for Golang runtime memory corruption bug”
  14. Submitted Perforce killed my productivity. Again as a story · 1 points

    HN discussion
  15. You should clarify your terminology: -- "context switch" (expensive) is the switch among active (running on this CPU) tasks/threads/processes. -- switching between kernel and userspace would be "mode switch", much less expensive and of "constant" cost (see, for example, http://blog.tsunanet.net/2010/11/how-long-does-it-take-to-ma... ). Your phrase already carries this contradiction: "__can__ be fairly expensive" poi…

    Comment linking /2010/11/how-long-does-it-take-to-make-context.html

    on “Unicore: A new Unikernel project”
  16. "Context switching is expensive. My rule of thumb is that it'll cost you about 30µs of CPU overhead. This seems to be a good worst-case approximation. Applications that create too many threads that are constantly fighting for CPU time (such as Apache's HTTPd or many Java applications) can waste considerable amounts of CPU cycles just to switch back and forth between different threads." http://blog.tsunanet.net/2010/…

    Comment linking /2010/11/how-long-does-it-take-to-make-context.html

    on “Dyad: Minimal, portable async networking library for C”
  17. A case of only so many words in the English language. Easy to fix if we distinguish hardware fast path from the software variant. Software fast paths are worth looking into since context switches are costly to the tune of thousands of CPU cycles [0,1]. Those thousands of CPU instructions going up in smoke could've done quite a lot of useful work. [0] http://blog.tsunanet.net/2010/11/how-long-does-it-take-to-ma... [1…

    Comment linking /2010/11/how-long-does-it-take-to-make-context.html

    on “New approaches to network fast paths”
  18. I enjoyed it when I first read it a couple of years ago and the recent blog post from tsuna on context switching reminded me of it ( http://blog.tsunanet.net/2010/11/how-long-does-it-take-to-ma... ). Glad to see some other folks like it, as well.

    Comment linking /2010/11/how-long-does-it-take-to-make-context.html

    on “A Comparison of Software and Hardware Techniques for x86 Virtualization”

Search all of HN for blog.tsunanet.net

Linked by the same people?