News for hackers. Stuff that matters.
Re:Goroutines and APIs by ridiculous_fish on Tuesday November 19, 2019 @12:22AM (#21570830)
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?

Re:Goroutines and APIs by denormalfloat on Tuesday November 19, 2019 @03:14AM (#21571391)
Yes, 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+.

Re:Goroutines and APIs by sagichmal on Tuesday November 19, 2019 @12:35AM (#21570864)
Which 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.
Re:Goroutines and APIs by ridiculous_fish on Tuesday November 19, 2019 @12:52AM (#21570923)
For example os.Stat()
Re:Goroutines and APIs by sagichmal on Tuesday November 19, 2019 @01:52AM (#21571113)
Interesting, I've never encountered a situation where that kind of thing matters, out of curiosity what are your use cases?