Summary
- Disable the collection of
PerfData
events using an always-on periodic task (StatSampler
). - Deprecate and obsolete the then unused
PerfDataSamplingInterval
flag. - Update
jstat -t
to calculate timestamps as offsets fromsun.rt.createVmBeginTime
instead of relying on sampled timestamps.
Problem
The StatSampler
, a small periodic task in PerfData
, runs every 50ms but is rarely used in practice. Its impact varies by GC:
- G1/ZGC: Only records the current time in the shared
perfdata
file. - Serial/Parallel GC: Updates heap usage counters (for eden, young, and old gen) in the shared file (values are copied from internal storage; JMX users remain unaffected). This is also done independently after each GC cycle.
- Note: Since counters are only updated post-GC, the reported eden usage without sampling will always be 0 (eden is empty after a GC cycle).
- No other sampling occurs.
The periodic sampling offers little benefit:
- Heap usage counters are already updated each GC cycle.
- The sampled timestamps are seldom used.
- Most run G1/ZGC where the task only collects timestamps.
- The sampling feature has remained effectively unused by developers since it became available.
The flag PerfDataSamplingInterval
controls how often this sampling occurs, and is set to 50ms as default. This flag is obscure, only having a use with jstat and older GCs. Searching for this flag yields barely any results, and no results from tutorials or tuning guides. Thus, removing this flag should be very low risk and have little impact on users.
Solution
- Remove the
StatSampler
and associated sampling logic. - Deprecate and obsolete
PerfDataSamplingInterval
(unused after sampling removal). - Handle
sun.os.hrt.ticks
(the sampled timestamp):- Remove or initialize it once (to
os::elapsed_counter
at startup).
- Remove or initialize it once (to
- Change
jstat -t
to usesun.rt.createVmBeginTime
instead ofsun.os.hrt.ticks
by calculating timestamps as offsets from VM start time.
Specification
- Remove the periodic task (
StatSampler
) and associated sampling logic. PerfDataSamplingInterval
:- Deprecated/obsoleted in JDK 25, marked for removal in JDK 26.
jstat -t
:- Calculate each timestamp using VM start time instead of sampling.
- csr of
-
JDK-8241678 Remove PerfData sampling via StatSampler
-
- Open
-