Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8241701

Remove PerfData sampling via StatSampler

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Unresolved
    • Icon: P4 P4
    • 25
    • hotspot
    • None
    • behavioral
    • low
    • add/remove/modify command line option
    • JDK

      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 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. Deprecate and obsolete PerfDataSamplingInterval (unused after sampling removal).
      3. Handle sun.os.hrt.ticks (the sampled timestamp):
        • Remove or initialize it once (to os::elapsed_counter at startup).
      4. Change jstat -t to use sun.rt.createVmBeginTime instead of sun.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.

            cnorrbin Casper Norrbin
            redestad Claes Redestad
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: