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. The fix looks good to me. It is important and nice simplification. The JVMTI part is strait forward. ------------- Marked as reviewed by sspitsyn (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/21735#pullrequestreview-2403758889