RFR: 8322732: ForkJoinPool may underutilize cores in async mode [v17]

Viktor Klang vklang at openjdk.org
Fri May 31 14:38:05 UTC 2024


On Fri, 31 May 2024 14:24:56 GMT, Doug Lea <dl at openjdk.org> wrote:

>> src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java line 2024:
>> 
>>> 2022:                                 }
>>> 2023:                                 if (pb == (pb = b))       // base unchanged
>>> 2024:                                     Thread.onSpinWait();
>> 
>> @DougLea Doesn't this mean that we'll always onSpinWait at least once here (since pb is initialized to -1 and not written until this check)
>
> No, almost the opposite: it only spinWaits if base is apparently stuck, except (harmlessly) every 4B encounters when it happens to be -1. (The value -1 works best here since base starts at 0 and is simpler than other ways of checking for stalls.)

@DougLea You're right, I've seen too many of these consistency-checks to have my brain read "!=" automatically. Sorry for the noise :)

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/19131#discussion_r1622520678


More information about the core-libs-dev mailing list