RFR: JDK-8319662 ForkJoinPool trims worker threads too slowly [v3]

Viktor Klang vklang at openjdk.org
Thu Nov 23 10:59:10 UTC 2023


On Tue, 21 Nov 2023 17:12:39 GMT, Doug Lea <dl at openjdk.org> wrote:

>> This update cascades timeouts to trim subsequent workers after the first  keepAlive inactive period.
>
> Doug Lea has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:
> 
>  - Merge branch 'openjdk:master' into JDK-8319662
>  - tweak cascades; reinstate an @Contended; resolve JDK-8319498
>  - Support cascading idle timeouts

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

> 2011:                 else if ((e & SHUTDOWN) == 0)
> 2012:                     return true;
> 2013:                 else if (compareAndSetCtl(c, c) && casRunState(e, e | STOP)) {

Is this `compareAndSetCtl(c, c)` really needed? Wouldn't a volatile get on `ctl` compared with `c` be enough? (Or are we relying on a store-barrier in the successful case? 🤔

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16725#discussion_r1403218297


More information about the core-libs-dev mailing list