The user can choose a thread implementation - all kernel, all user-mode, or part kernel/part usermode - without changing any code. We've introduced the concept of a pluggable custom scheduler, and that could be used for kernel threads just as it's used for virtual threads. > This seems to be a response to Google's switchto work in the Linux kernelĪctually, it's a response to a discussion where somebody asked, "isn't it all about context-switch cost?" But user-scheduled kernel thread is something we had in mind when designing Loom, and we've made sure we can be compatible with them. Take stack size for example: assuming the kernel stack is 10kB, if your thread itself uses 10kB of stack, you've cut the theoretical memory advantage of M:N down from the cited 1000x to a mere 2x… My suspicion is that Amdahl's Law is going to quickly rear its head here. But for the thread-per-connection server use case, I'm not sure how expensive this cost is relative to all the other work that the thread does.
Linux per thread kernel stack size generator#
For the generator use case, I can easily see how the kernel thread spawn operation is the bottleneck. This is something I'd like to see more of a focus on. Note the parenthetical in the article: "And that is how user-mode threads help: they increase L by orders of magnitude with potentially millions of user-mode threads instead of the meager thousands the OS can support (but don’t expect a 1000x increase in capacity we’ve neglected computation costs and are bound to hit bottlenecks in the auxiliary services.)" This seems to be a response to Google's switchto work in the Linux kernel, which is motivated by task-switching costs, as per this 2013 LPC presentation.