RFR: 8338383: Implement JEP 491: Synchronize Virtual Threads without Pinning [v3]
Alan Bateman
alanb at openjdk.org
Fri Oct 25 10:24:16 UTC 2024
On Thu, 24 Oct 2024 22:13:27 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> We don't unmount the virtual thread here, we just temporarily change the thread identity. You could think of this method as switchIdentityToCarrierThread if that helps.
>
> Sorry to belabour this but why are we temporarily changing the thread identity? What is the bigger operation that in underway here?
We've had these temporary transitions from day 1. The changes in this PR remove one usage, they don't add any new usages. The intention is to make this nuisance go away. The last usage requires changes to the timer support, working on it. For now, it's easiest to think of it as a "java on java" issue where critical code is in Java rather than the VM. The timer issue arises when a virtual thread does a timed park needs to schedule and cancel a timer. This currently requires executing Java code that may contend on a timer or trigger a timer thread to start. This has implications for thread state, the park blocker, and the parking permit. Adding support for nested parking gets very messy, adds overhead, and is confusing for serviceability observers. The exiting behavior is to just temporarily switch the thread identity (as in Thread::currentThread) so it executes in the context of the carrier rather than the virtual thread. As I said, we are working to make this go away, it would have
been nice to have removed in advance of the changes here.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21565#discussion_r1816425590
More information about the serviceability-dev
mailing list