RFR: 8360046: Scalability issue when submitting virtual threads with almost empty tasks [v10]

Doug Lea dl at openjdk.org
Mon Sep 22 12:05:33 UTC 2025


On Mon, 22 Sep 2025 10:54:15 GMT, Viktor Klang <vklang at openjdk.org> wrote:

>> Doug Lea has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Add @Contended WorkQueue region. Adapt accordingly.
>
> src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java line 2030:
> 
>> 2028:         int idle = 1;
>> 2029:         if (w != null) {                        // always true; hoist checks
>> 2030:             int activePhase = (w.phase += IDLE) + IDLE; // advance
> 
> This will add IDLE twice to activePhase?

Made less confusing by breaking into:
            int inactivePhase = w.phase |= IDLE; // set status
            int activePhase = inactivePhase + IDLE; // phase value when reactivated

> src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java line 2034:
> 
>> 2032:             do {                                // enqueue
>> 2033:                 qc = ap | ((pc - RC_UNIT) & UMASK);
>> 2034:                 w.stackPred = (int)pc;          // set ctl stack link
> 
> Is it worth updating w.stackPred every time before a failing CAS of pc, qc? Is the intent to flush that change when the CAS succeeds?

We need to write stackPred before each CAS attempt to avoid data race when signalling

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26479#discussion_r2367966760
PR Review Comment: https://git.openjdk.org/jdk/pull/26479#discussion_r2367976091


More information about the core-libs-dev mailing list