JDK-8241701 : Remove PerfData sampling via StatSampler
  • Type: CSR
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 25
  • Submitted: 2020-03-26
  • Updated: 2025-04-29
  • Resolved: 2025-04-29
Related Reports
CSR :  
Description
## Summary

-   Disable the collection of  `PerfData`  events using an always-on periodic task (`StatSampler`).
-   Obsolete the then unused  `PerfDataSamplingInterval`  flag.
-   Update  `jstat -t`  to calculate timestamps as offsets from `sun.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

1.  Remove the  `StatSampler`  and associated sampling logic.
2.  Obsolete  `PerfDataSamplingInterval`  (unused after sampling removal).
3.   Change `jstat -t` to calculate timestamps using offsets from VM start time instead of sampled timestamps.

## Specification

-   Remove the periodic task (`StatSampler`) and associated sampling logic.
-   `PerfDataSamplingInterval`:
    -   Obsoleted in JDK 25, marked for removal in JDK 26.
-   `jstat -t`:
    -   Calculate each timestamp using VM start time instead of sampling.
Comments
Moving to Approved.
29-04-2025

Moving to Provisional, not Approved. [~cnorrbin], please have one or more other engineers review the CSR before it is re-Finalized.
22-04-2025

Worth noting that this is the man page description of `jstat -t`: -t Displays a time-stamp column as the first column of output. The time stamp is the time since the start time of the target JVM. This change would bring it closer to the actual description, as it now accurately describes actual wall time since start.
22-04-2025

[~darcy] Please see the revised proposal. We can preserve `jstat -t` functionality by calculating the timestamp rather than sampling. Without this change, the feature would indeed break if sampling is removed. The only user-facing impact now would be the removal of the `PerfDataSamplingInterval` flag.
10-04-2025

Moving to Provisional, not Approved. Assuming this work is intended for JDK 25. > Deprecate jstat -t: No longer supported due to removed time sampling. So are you proposing that `jstat -t` in this release be _deprecated_, as in the functionality still works but will be removed in the future, or _removed_ in this release because it doesn't work anymore? > > jstat -t: > > Flag deprecated; man pages updated to reflect this. The solution section of the CSR needs to reflection this man page update.
08-04-2025