3 ms·
Some operations can use green threads, while others need kernel threads. Last I tried (~2015) Go would spawn unlimited kernel threads, so function callers had t
by ridiculous_fish 7y ago
Some operations can use green threads, while others need kernel threads. Last I tried (~2015) Go would spawn unlimited kernel threads, so function callers had to know whether a call required a kernel thread or not, and rate-limit appropriately.
Is this still the case? How does modern Go handle operations which require kernel threads?
- sagichmal 7y agoWhich operations need kernel threads? There is runtime.LockOSThread if you need underlying thread affinity, but I'm not aware of any other mechanism to interact with the underlying threads of execution.
- ridiculous_fish 7y agoFor example os.Stat()
- sagichmal 7y agoInteresting, I've never encountered a situation where that kind of thing matters, out of curiosity what are your use cases?
- denormalfloat 7y agoYes, they still need unlimited kernel threads (for liveness reasons). When I asked a few years back about this, go-nuts@ suggested implemented my own rate limiting in application space. In my case, it was for running Go on a resource constrained Raspberry-PI, where the kernel threads could easily live too long, and use up all memory. The threads were calling read(2) on a network mounted fuse fs, and would last for 30s+.