On Thu, 16 Feb 2023 17:10:17 GMT, Paul Sandoz <psan...@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`). @PaulSandoz I'm usually a bit weary of piggybacking if it is not done on the same object, as future reorderings of the code might break that assumption. I wouldn't want to break anything silently so I made a rather conservative change. On which side should I err? :) ------------- PR: https://git.openjdk.org/jdk/pull/12320