mmap in Go considered harmful

13 points by runxiyu


jtolio

Note that this blog post is from 2018, which is before changes to Go's preemption strategy. Check out this 2020 GopherCon talk about how Go handles preemption these days: https://www.youtube.com/watch?v=1I1WmeSjRSw

olliej

Oh, I see, this is a bad title, it is about MMIO. From there it sounds like Go uses virtual threads/fibers/whatever-they're-call-this-decade - so because the IO page faults can happen at any point your working "thread" gets blocked but more work cannot then be scheduled because there's only one real thread. This is a standard problem with virtual threads not Go specific (see also virtual threads breaking forward progress guarantees that depend on tasks being guaranteed to get cpu time).

runxiyu

Oh, apparently go may require prefaulting mmap is similar

shanemhansen

So crazily enough, I've been thinking about this exact blog post for over a decade. Ever since I thought "hey, a page fault on swap would probably really mess up the go scheduler because it's really going to block the underlying thread (M in go terminology iirc properly)".

Thanks to Valyala for writing this and sharing!