Project Loom VirtualThreads hang
Alan Bateman
Alan.Bateman at oracle.com
Tue Jan 3 14:10:53 UTC 2023
On 28/12/2022 13:07, Robert Engels wrote:
> Alan,
>
> I tested with JDK 20 and both the VThreadTest and SpinTest complete successfully using Thread.yield!
>
> Surprisingly, it is slower than using LockSupport.parkNanos(1) - 14 secs vs 7 secs I am not sure this makes sense - as conceptually a thread yield should be at least as efficient as a 0 time sleep - and probably more efficient.
A timed park for very short <1us durations (or in particular <250ns) is
problematic in that the timeout may be reached before the virtual thread
has fully parked. In that case, it may get re-scheduled on the same
carrier rather than bouncing between carriers as might happen with
Thread.yield. So that might partly explain what you are seeing. Also 7
and 14s is very short run for a benchmark. I think I'd need to see the
benchmark to know what you are testing.
-Alan
More information about the loom-dev
mailing list