The Unscalable, Deadlock-prone, Thread Pool
https://pvk.ca/Blog/2019/02/25/the-unscalable-thread-pool/ [pvk.ca]
2019-02-27 03:42
Thread pools tend to only offer a sparse interface: pass a closure or a function and its arguments to the pool, and that function will be called, eventually. Functions can do anything, so this interface should offer all the expressive power one could need. Experience tells me otherwise.
This post comes in two parts. First, the story of a simple program that’s parallelised with a thread pool, then hits a wall as a wider set of resources becomes scarce. Second, a solution I like for that kind of program: an explicit state machine, where each state gets a dedicated queue that is aware of the state’s resource requirements.
source: HN