On Tue, 31 Jan 2023 10:57:58 GMT, Viktor Klang <d...@openjdk.org> wrote:
> I noticed when looking at the code that there was no real need to use a CHM > to perform the tracking of activation in an ordered fashion on > ForEachOrderedTask, but instead a VarHandle can be used, reducing allocations > and indirection. src/java.base/share/classes/java/util/stream/ForEachOps.java line 431: > 429: // leftChild and rightChild were just created and not > fork():ed > 430: // yet so no need for a volatile write > 431: NEXT.set(leftChild, rightChild); Make `next` a plain field and shuffle up the assignment (`leftChild.next = rightChild`) to occur immediately after construction of the right child task? (FWIW `addToPendingCount` operates on a volatile field of `CountedCompleter`). ------------- PR: https://git.openjdk.org/jdk/pull/12320