[concurrency-interest] Backpressure in ExecutorService with uneven length jobs
shevek at anarres.org
Tue Oct 3 07:36:07 EDT 2017
Dear list, I cannot be the first to ask...
In a previous discussion, it was suggested that using CallerRunsPolicy
with a queue of (say) ncpus * 10 is the canonical way to achieve
backpressure. However, when the jobs are of particularly uneven sizes,
sometimes the caller gets a job which runs for so long that all the
worker threads exhaust the queue and sit idle. I don't have a good bound
for the unevenness of jobs, and I have a 32-way Xeon.
Is there a good solution to this? Perhaps blocking the caller in
submit() until space is available in the queue? Would I better write my
own queue implementation, or wrap the executor in a semaphore?
It's not obviously amenable to an FJP: It's 3 million independent tasks,
one per node in a graph, although if the answer is "Yes, make an FJP,
and this is roughly how to make task-stealing do re-balancing", I'll be
More information about the Concurrency-interest