On Tue, 18 Jun 2024 21:01:15 GMT, Daniel Jeliński <djelin...@openjdk.org> wrote:

> We use 2 ParkEvent instances per thread. The ParkEvent objects are never 
> freed, but they are recycled when a thread dies, so the number of live 
> ParkEvent instances is proportional to the maximum number of threads that 
> were live at any time.
> 
> On Windows, the ParkEvent object wraps a kernel Event object. Kernel objects 
> are a limited and costly resource. In this PR, I replace the use of kernel 
> events with user-space synchronization.
> 
> The new implementation uses WaitOnAddress and WakeByAddressSingle methods to 
> implement synchronization. The methods are available since Windows 8. We only 
> support Windows 10 and newer, so OS support should not be a problem.
> 
> WaitOnAddress was observed to return spuriously, so I added the necessary 
> code to recalculate the timeout and continue waiting.
> 
> Tier1-5 tests passed. Performance tests were... inconclusive. For example, 
> `ThreadOnSpinWaitProducerConsumer` reported 30% better results, while 
> `LockUnlock.testContendedLock` results were 50% worse. 
> 
> Thoughts?

This is interesting. This is not an API I had heard of before now. I'm curious 
about how it works under the covers (some kind of hashtable of watched 
addresses I assume) and what its performance and memory profile is like when 
large numbers of threads may be involved. Hopefully it is early enough in the 
release cycle to catch any issues.

Note that there are still some references to WaitForSingleObject in the 
comments.

If this is simply a "lightweight event" mechanism then we could replace the 
other Event usages on Windows ... future RFE's of course.

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

PR Review: https://git.openjdk.org/jdk/pull/19778#pullrequestreview-2127034403

Reply via email to