On Thu, 7 Aug 2025 14:03:40 GMT, Doug Lea <d...@openjdk.org> wrote:

>> This set of updates reduces contention-based performance loss under heavy 
>> over-subscription, while also improving perfomance more generally.
>
> Doug Lea has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Avoid underutilization on resize

src/java.base/share/classes/java/util/concurrent/Exchanger.java line 380:

> 378:                                   
> (!ForkJoinWorkerThread.hasKnownQueuedWork()))) {
> 379:                             for (int j = SPINS; p.match == null && j > 
> 0; --j)
> 380:                                 Thread.onSpinWait();

It might not be worth it, but I wonder if something like this would make a 
positive impact:

Suggestion:

                        if (!(tryCancel = (deadline != 0L &&
                             (ns = deadline - System.nanoTime()) <= 0L) ||
                            Thread.currentThread().isInterrupted()))
                            && ncpu > 1 &&
                             (i != 0 || /* check for busy VTs */ 
(!ForkJoinWorkerThread.hasKnownQueuedWork()))) {
                            for (int j = SPINS; p.match == null && j > 0; --j)
                                Thread.onSpinWait();

src/java.base/share/classes/java/util/concurrent/Exchanger.java line 408:

> 406:                             if (Thread.interrupted())
> 407:                                 throw new InterruptedException();
> 408:                             if (deadline != 0L && ns <= 0L)

Is the reasoning here that `deadline` cannot be == 0L, or that it doesn't 
matter anymore if it is?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26479#discussion_r2276356973
PR Review Comment: https://git.openjdk.org/jdk/pull/26479#discussion_r2276362959

Reply via email to