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

Viktor Klang vklang at openjdk.org
Thu Sep 11 13:21:00 UTC 2025


On Sun, 7 Sep 2025 18:28:54 GMT, Doug Lea <dl at 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:
> 
>   revive topLevelExec, adjust occrdingly; small teaks and copy-edits

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

> 1222:             if ((this.owner = owner) == null) {
> 1223:                 phase = id | IDLE;
> 1224:                 array = new ForkJoinTask<?>[INITIAL_QUEUE_CAPACITY];

Might be better to assign the array *before* assigning the phase as the latter is a volatile write?

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

> 1949:     final void runWorker(WorkQueue w) {
> 1950:         if (w != null) {
> 1951:             int phase = w.phase;

Given that this is a volatile read, and presuming that the timing of this read is important, perhaps add a comment on this line?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26479#discussion_r2340815858
PR Review Comment: https://git.openjdk.org/jdk/pull/26479#discussion_r2340822551


More information about the core-libs-dev mailing list