RFR: 8336707: Contention of ForkJoinPool grows when stealing works [v29]

Viktor Klang vklang at openjdk.org
Tue Nov 19 17:00:59 UTC 2024


On Sun, 17 Nov 2024 15:33:02 GMT, Doug Lea <dl at openjdk.org> wrote:

>> This addresses tendencies in previous update to increase fencing, scanning, and signalling that can increase contention, and slow down performance especially on ARM platforms. It also uses more ARM-friendly constructions to reduce overhead (leading to several changes that all of the same form),
>
> Doug Lea has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Ensure InnocuousForkJoinWorkerThread usable with or without SecurityManager

src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java line 2780:

> 2778:                 now = true;
> 2779:         }
> 2780:         if (now) {

@DougLea I'd probably add a blank line above this one to signal that this if is not a part of the previous if-else chain.

src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java line 2805:

> 2803:             }
> 2804:         }
> 2805:         return e;

@DougLea Is there any benefit to using `break` in the loop rather than `return e;` directly?

src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java line 2838:

> 2836:                         }
> 2837:                     }
> 2838:                     else if ((q.phase & (IDLE|1)) == 0 ||

@DougLea What's the intent of the `|1` part here? 🤔

src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java line 4082:

> 4080:             AccessController.doPrivileged(new PrivilegedAction<>() {
> 4081:                     public ForkJoinPool run() {
> 4082:                         return new ForkJoinPool((byte)0); }});

@AlanBateman Any recommendation as to what is ideal here with SM removed? /cc @DougLea

src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java line 247:

> 245:         = U.objectFieldOffset(Thread.class, "threadLocals");
> 246:     private static final long INHERITABLETHREADLOCALS
> 247:         = U.objectFieldOffset(Thread.class, "inheritableThreadLocals");

@AlanBateman Thoughts here? 🤔

src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java line 270:

> 268:         @SuppressWarnings("removal")
> 269:         public void setContextClassLoader(ClassLoader cl) {
> 270:             if (System.getSecurityManager() != null &&

@AlanBateman Alternatives for this? 🤔

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21507#discussion_r1848717378
PR Review Comment: https://git.openjdk.org/jdk/pull/21507#discussion_r1848720748
PR Review Comment: https://git.openjdk.org/jdk/pull/21507#discussion_r1848722786
PR Review Comment: https://git.openjdk.org/jdk/pull/21507#discussion_r1848724803
PR Review Comment: https://git.openjdk.org/jdk/pull/21507#discussion_r1848727422
PR Review Comment: https://git.openjdk.org/jdk/pull/21507#discussion_r1848728622


More information about the core-libs-dev mailing list