On Mon, 28 Oct 2024 08:34:14 GMT, Alan Bateman <al...@openjdk.org> wrote:
> This is an update to the Virtual thread implementation that we'd like to > integrate in advance of JEP 491. > > The update removes the use of "temporary transitions", basically cases where > the thread identity switches to the carrier thread to do something in the > context of the carrier while a virtual thread is mounted. These cases create > complexity for JVMTI and observability tools. It has also attracted attention > in the review of the JEP 491 implementation as the object monitor changes > have to deal with the possibility of entering monitors while in this state. > There are 3 usages changes: > > 1. In submitRunContinuation the submit to the scheduler is changed so that it > executes in the context of a virtual thread for cases where one virtual > thread unparks another. This requires pinning to prevent preemption during > this sensitive operation. ForkJoinPool.poolSubmit is changed so that it uses > the identity of the carrier. This change has no impact on the uses of > lazySubmit or externalSubmit. > 2. Timed-park. The current implementation schedules/cancels the timer task > with the virtual thread mounted. This runs in the context of the carrier as > any contention would infer with thread state, park blocker and the parking > permit. The implementation is changed to schedule the timeout after > unmounting, and to cancel before re-mounting. The downside of this is that it > will scheduled later (maybe 200us later than before). We could capture the > time and adjust but it doesn't seem worth it. > 3. jdk.tracePinnedThreads. This is a diagnostic option for finding usages of > thread locals in code executed by virtual threads. This is changed so use a > thread local to detect reentrancy. > > The changes means that notifyJvmtiHideFrames, its intrinsic, and the JVMTI > "tmp VTMS_transition" bit go away. This pull request has now been integrated. Changeset: dee0982c Author: Alan Bateman <al...@openjdk.org> URL: https://git.openjdk.org/jdk/commit/dee0982c603b389148a2e615c10c1276c3c589ae Stats: 354 lines in 16 files changed: 91 ins; 170 del; 93 mod 8343132: Remove temporary transitions from Virtual thread implementation Reviewed-by: dholmes, sspitsyn, pchilanomate ------------- PR: https://git.openjdk.org/jdk/pull/21735