On Mon, 12 Aug 2024 17:07:42 GMT, Doug Lea <d...@openjdk.org> wrote:

> The Exchanger class uses spin-waits that are hostile to some uses of 
> VirtualThreads. Improving this requires a means of estimating whether there 
> are many VirtualThreads with few carriers, which can be supported by adding a 
> method in class ForkJoinWorkerThread. This enables a reworking of the 
> exchange method, and can also be used to deal with similar issues in 
> LinkedTransferQueue and possibly elsewhere. We leave for now open whether 
> this method (hasKnownQueuedWork) should be public, which would allow users to 
> use it in similar contexts, at the possible expense of revealing too much 
> about current VT implementation

I had forgotten that there was already a stripped-down jtreg version of an 
Exchanger test in test/jdk/java/util/concurrent/Exchanger. So I updated it to 
include virtual, platform and mixes. (Also including enough iterations and 
stages to reduce noisiness. Here's a sample run:
Warmup...
Threads: 2 PLATFORM     :       195 ns per transfer
Threads: 3 PLATFORM     :       226 ns per transfer
Threads: 4 PLATFORM     :       172 ns per transfer
Threads: 5 PLATFORM     :       148 ns per transfer
Threads: 6 PLATFORM     :       123 ns per transfer
Threads: 7 PLATFORM     :       100 ns per transfer
Threads: 8 PLATFORM     :        96 ns per transfer
Threads: 9 PLATFORM     :        78 ns per transfer
Threads: 2 VIRTUAL      :       185 ns per transfer
Threads: 3 VIRTUAL      :       223 ns per transfer
Threads: 4 VIRTUAL      :       194 ns per transfer
Threads: 5 VIRTUAL      :       139 ns per transfer
Threads: 6 VIRTUAL      :       121 ns per transfer
Threads: 7 VIRTUAL      :       118 ns per transfer
Threads: 8 VIRTUAL      :       190 ns per transfer
Threads: 9 VIRTUAL      :        79 ns per transfer
Threads: 2 MIXED        :       161 ns per transfer
Threads: 3 MIXED        :       196 ns per transfer
Threads: 4 MIXED        :       164 ns per transfer
Threads: 5 MIXED        :       146 ns per transfer
Threads: 6 MIXED        :       123 ns per transfer
Threads: 7 MIXED        :       106 ns per transfer
Threads: 8 MIXED        :       102 ns per transfer
Threads: 9 MIXED        :        87 ns per transfer

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

PR Comment: https://git.openjdk.org/jdk/pull/20554#issuecomment-2302143653

Reply via email to