Make hsperf counter sun.threads.total_gc_cpu_time in sync with individual counters

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: P4
    • tbd
    • Affects Version/s: 22
    • Component/s: hotspot
    • svc
    • 22

      JDK-8315149 introduced hsperf counter `sun.threads.total_gc_cpu_time` for the total CPU consumed by various GC threads. As pointed out during code review ( https://github.com/openjdk/jdk/pull/15082 ), the total_gc_cpu_time may not be updated frequently enough and could be out-of-sync with respect to individual GC CPU counters (sun.threads.cpu_time.gc_*).

      We'd like to switch to update total_gc_cpu_time counter in the ~ThreadTotalCPUTimeClosure() destructor, i.e., every time an individual sun.threads.cpu_time.gc_* counter is updated. This will also simplify the code as we can get rid of the `CPUTimeCounters::inc_gc_total_cpu_time()` and `CPUTimeCounters::publish_gc_total_cpu_time()` functions.

      There are two ideas to solve this:
      1. Introduce a lock to guard the updates to sun.threads.total_gc_cpu_time counter.
      2. Introduce a `PerfAtomicCounter` class, which is a PerfCounter than supports `Atomic::add()`.

            Assignee:
            Jonathan Joo
            Reporter:
            Man Cao
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: