[concurrency-interest] CHM.compute restrictions

Peter Levart peter.levart at gmail.com
Tue Aug 7 12:12:04 EDT 2018


Looking at stack trace, it can be seen that this is indeed taking the place:

     at 
java.util.concurrent.ConcurrentHashMap.compute(java.base at 10.0.2/ConcurrentHashMap.java:1938)
     - waiting to lock <0x00000006cfb30b58> (a 
java.util.concurrent.ConcurrentHashMap$ReservationNode)
     at 
com.upserve.NestedParallel.lambda$streamParallelOuterTask$4(NestedParallel.java:87)
     at com.upserve.NestedParallel$$Lambda$6/354291670.accept(Unknown 
Source)
     at 
java.util.stream.ForEachOps$ForEachOp$OfLong.accept(java.base at 10.0.2/ForEachOps.java:225)
     at 
java.util.Random$RandomLongsSpliterator.forEachRemaining(java.base at 10.0.2/Random.java:1099)
     at 
java.util.Spliterator$OfLong.forEachRemaining(java.base at 10.0.2/Spliterator.java:763)
     at 
java.util.stream.AbstractPipeline.copyInto(java.base at 10.0.2/AbstractPipeline.java:484)
     at 
java.util.stream.ForEachOps$ForEachTask.compute(java.base at 10.0.2/ForEachOps.java:290)
     at 
java.util.concurrent.CountedCompleter.exec(java.base at 10.0.2/CountedCompleter.java:746)
     at 
java.util.concurrent.ForkJoinTask.doExec(java.base at 10.0.2/ForkJoinTask.java:290)
     at 
java.util.concurrent.*ForkJoinPool.awaitJoin*(java.base at 10.0.2/ForkJoinPool.java:1713)
     at 
java.util.concurrent.ForkJoinTask.doJoin(java.base at 10.0.2/ForkJoinTask.java:397)
     at 
java.util.concurrent.ForkJoinTask.get(java.base at 10.0.2/ForkJoinTask.java:1004)
     at 
com.upserve.NestedParallel.streamParallelInnerTask(NestedParallel.java:172)
     at 
com.upserve.NestedParallel.lambda$biFunction$9(NestedParallel.java:147)
     at com.upserve.NestedParallel$$Lambda$12/1333040169.apply(Unknown 
Source)
     at 
java.util.concurrent.ConcurrentHashMap.compute(java.base at 10.0.2/ConcurrentHashMap.java:1922)

ForkJoinPool.awaitJoin - is a method that awaits for the task to 
complete while helping to execute other tasks so that the thread is not 
wasted. In above stack trace, the task executing awaitJoin is an inner 
task, while the task being executed by awaitJoin is an outer task.

To avoid that, outer and inner tasks should not share the same ForkJoinPool.

Regards, Peter

On 08/07/2018 05:32 PM, David Stuebe wrote:
>
> Hi Peter, Doug
>
> That is very interesting!
>
> I am not sure I fully grok your explanation, but it did suggest 
> changing the inner task pool to be a fixed thread pool rather than a 
> forkjoin pool. This appears to alleviate the issue!
>
> More experiments to follow.
>
> David

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20180807/5283d8ab/attachment.html>


More information about the Concurrency-interest mailing list