On Thu, 15 Jan 2026 12:39:43 GMT, Viktor Klang <[email protected]> wrote:
>> Doug Lea has updated the pull request incrementally with one additional
>> commit since the last revision:
>>
>> Another set of contend vs deactivate vs park tradeoffs
>
> src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java line 1861:
>
>> 1859: break;
>> 1860: }
>> 1861: }
>
> The following might be a potential alternative encoding of signalWork—it
> would be interesting to hear if it makes any difference on your testing
> array, Doug:
>
>
> final void signalWork(WorkQueue src, int base) {
> int pc = parallelism, i, sp; // rely on caller sync for initial reads
> long c = U.getLong(this, CTL);
> WorkQueue[] qs;
> while ((short)(c >>> RC_SHIFT) < pc && (qs = queues) != null &&
> qs.length > (i = (sp = (int)c) & SMASK) && (src == null ||
> src.base - base < 1)) {
> if (i == 0) {
> if ((short)(c >>> TC_SHIFT) >= pc)
> break;
> if (c == (c = U.compareAndExchangeLong(this, CTL, c, ((c +
> TC_UNIT) & TC_MASK) | ((c + RC_UNIT) & RC_MASK)))) {
> createWorker();
> break;
> }
> }
> else {
> WorkQueue v;
> if ((v = qs[i]) == null)
> break;
> if (c == (c = U.compareAndExchangeLong(this, CTL, c,
> (v.stackPred & LMASK) | ((c + RC_UNIT) & UMASK)))) {
> v.phase = sp;
> if (v.parking != 0)
> U.unpark(v.owner);
> break;
> }
> }
> }
> }
Thanks for prodding me to instrument current version. I saw that retries are no
longer very common -- max seen across various contention-prone tests was 17,
but in most never more than 4 except more during warmup before code is
compiled. Versions that did filter check before CAS systematically have more
retries though. And as I noticed in some previous versions, separating the
branches with different CAes invites the compiler to rearrange code in a worse
way to only have one CAS. at least in the surprisingly common case where it
inlines signalWork in callers. So net change from all this so far was a couple
of cosmetic tweaks.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28797#discussion_r2702638385