RFR: 8336707: Contention of ForkJoinPool grows when stealing works

Viktor Klang vklang at openjdk.org
Fri Oct 18 12:35:17 UTC 2024


On Fri, 18 Oct 2024 12:27:34 GMT, Doug Lea <dl at openjdk.org> wrote:

>> src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java line 1913:
>> 
>>> 1911:                 if (!all)
>>> 1912:                     break;
>>> 1913:             }
>> 
>> Stylistically, it might be cleaner to do this:
>> 
>> Suggestion:
>> 
>>         do {
>>             WorkQueue[] qs; WorkQueue v; int sp, i;
>>             if ((sp = (int)c) == 0 || (qs = queues) == null ||
>>                 qs.length <= (i = sp & SMASK) || (v = qs[i]) == null)
>>                 break;
>>             if (c == (c = compareAndExchangeCtl(
>>                           c, ((UMASK & (c + RC_UNIT)) | (c & TC_MASK) |
>>                               (v.stackPred & LMASK))))) {
>>                 v.phase = sp;
>>                 if (v.parking != 0)
>>                     U.unpark(v.owner);
>>             } while(all);
>
> Yeah, except not quite that way, since the break should occur only if the CAS succeeds. I'll try other options.

Ah, I see what you mean, I must've inferred a closing brace before.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21507#discussion_r1806415929


More information about the core-libs-dev mailing list