14 ms·
Scheduling in Go: Part II
- lostmsu 8y agoThe sad part of the story is that now we have yet another language, that lived off hype without bringing anything new to the table. BTW, TL;DR; is: Go uses per thread task queues with stealing, and an additional global one.
- weberc2 8y agoI don’t know. I appreciate having a simple language that lets me get things done quickly and mostly stays out of my way. Not just the type system or even the runtime mind you, but the ecosystem and tooling as well.
- the_other_guy 8y agoGreat article. I am really curious, what's the theoretical position of using coroutines/green threads vs native OS threads especially in Linux as of 2018? Was Golang right in choosing this model or Linux has become very efficient when it comes to creating and scheduling threads?
- 13415 8y agoThat's a good point, if you create only few green threads the overhead of dealing with them should nullify any advantage of lightweight scheduling and creating. Languages like Go like to advertise that you easily spawn millions of Green threads (which would fail with OS level threads or bring your OS down) but I've never seen a use case for that. For realistic applications a work stealing OS thread pool should be faster than spawning lots of green threads. But in the end, performance has to be measured, of course.
- skybrian 8y agoAre you assuming async I/O? For a thread-per-request architecture with blocking reads and writes, it seems like green threads will work better.
- thepumpkin1979 8y agoInteresting, in my mind the memory usage of M threads is too expensive when you’re mostly waiting for network or file system events, the advantage I remember from green threads is that the thread can be used to execute another CPU bound task while waiting for network events which intrinsically makes it more memory efficient. I’m interested in how Linux has evolved to reduce memory consumption when you have millions of threads, because you can have millions of green threads.
- pcwalton 8y agoMost of the memory usage comes from the user stack, and you can customize the size of the stack. So memory consumption isn't really the limiting factor here. More important is the cost of context switching.