3 ms·
Starts off with: don't. And then goes in to some very different i/o & cpu bound methods to follow. The first of which examples is a thread pool backing parallel
by rektide 5y ago
Starts off with: don't. And then goes in to some very different i/o & cpu bound methods to follow. The first of which examples is a thread pool backing parallel iterators.
This comes hot on the heels of Thread Pools on the JVM[1], which suggested breaking up thread pools into cpu bound, i/o bound, and latency critical. To that effect, not sure what the guidance is here: what are good practices in Rust when you have different workloads running alongside each other?
Write-up looks good though, some good suggestions.
[1] https://news.ycombinator.com/item?id=27883847 https://news.ycombinator.com/item?id=27883847 , ~115 comments
- sylvain_kerkour 5y agoHello, Author here :) I did a bad job explaining what I consider to be a worker pool (i.e some kind of class that encourages statefulness and mutable data). My bad, I'll fix that. It's just a question of abstraction. > what are good practices in Rust when you have different workloads running alongside each other? Very good question! I will try to add my recommendations at the end of the post tonight. For the moment, I would say the best practice for this scenario is to use both rayon and a Stream. The thing is to be careful about how many CPU cores you allocate for the CPU bound tasks and how many for tokio's internal thread pool (it will depend on the workloads).