Before JDK-8352251, the JFR Sampler Thread held onto the Threads_lock during the entire sampling period when iterating threads.
This was for two purposes:
1. Having a non-Java thread sampler thread race through an ongoing safepoint, touching oops is generally not supported by most GCs.
2. Since the sampler thread is a non-Java thread, and a JavaThread to be sampled can be in thread state _thread_in_native, it means both threads are outside the safepoint protocol. JFR evolves its global epoch during a safepoint.
WithJDK-8352251, things have improved much. The sampling parts performed by the non-Java sampler thread do not touch any oops for threads sampled in state _thread_in_Java.
For sampling threads in native, the original issue persists (the sampler thread needs to capture the stack trace in the correct JFR epoch, and will also, in the case of virtual threads, need to touch oops).
However, we can significantly reduce the time the Threads_lock is held for sampling.
This was for two purposes:
1. Having a non-Java thread sampler thread race through an ongoing safepoint, touching oops is generally not supported by most GCs.
2. Since the sampler thread is a non-Java thread, and a JavaThread to be sampled can be in thread state _thread_in_native, it means both threads are outside the safepoint protocol. JFR evolves its global epoch during a safepoint.
With
For sampling threads in native, the original issue persists (the sampler thread needs to capture the stack trace in the correct JFR epoch, and will also, in the case of virtual threads, need to touch oops).
However, we can significantly reduce the time the Threads_lock is held for sampling.
- relates to
-
JDK-8352251 Implement JEP 518: JFR Cooperative Sampling
-
- Resolved
-
- links to
-
Commit(master) openjdk/jdk/b6d60280
-
Review(master) openjdk/jdk/25602