[concurrency-interest] ForkJoinPool with custom number of WorkQueues

Carl Mastrangelo notcarl at google.com
Thu Nov 8 18:16:31 EST 2018


Hi,

I am using ForkJoinPool as a means to avoid lock contention for submitting
tasks to an executor.  FJP is much faster than before, but has some
unexpected slowdown when there is not enough work.   In particular, A
significant amount of time is spent waiting parking and unparking threads
when there no work to do.  When there is no active work, it seems each
worker scans the other work queues looking for work before going to sleep.

In my program I have a parallelism of 64, because when the work load is
high, each of the threads can be active.  However, when work load is low,
the workers spend too much time looking for more work.

One way to fix this (I think) is to lower the number of worker queues, but
keep the same number of workers.   In my case, having 32 or 16 queues
rather than having exactly 64 might help, but I have no way of testing it
out.   Has this ever been brought up, or is it possible for me to easily
patch FJP to see if it would help?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20181108/d1379a8b/attachment.html>


More information about the Concurrency-interest mailing list