JDK-8373625 : CPUTimeCounters creates a total counter for unsupported GCs
  • Type: Bug
  • Component: hotspot
  • Sub-Component: svc
  • Affected Version: 22
  • Priority: P4
  • Status: New
  • Resolution: Unresolved
  • Submitted: 2025-12-12
  • Updated: 2025-12-12
Related Reports
Causes :  
Description
CPUTimeCounters unconditionally creates CPUTimeGroups::CPUTimeType::gc_total. Since only Parallel and G1 are supported by this framework/class, this leads to publishing a counter that always resolves to 0. This may be contradictory for an end-user especially so as we now support logging GC CPU time for any GC inside Hotspot. For an example using -Xlog:cpu we get

```
[7.907s][info][cpu] === CPU time Statistics =============================================================
[7.907s][info][cpu]                                                                             CPUs
[7.907s][info][cpu]                                                                s       %  utilized
[7.907s][info][cpu]    Process
[7.907s][info][cpu]      Total                                              186.9562  100.00      23.6
[7.907s][info][cpu]      Garbage Collection                                   0.6700    0.36       0.1
[7.907s][info][cpu]        GC Threads                                         0.6692    0.36       0.1
[7.907s][info][cpu]        VM Thread                                          0.0008    0.00       0.0
[7.907s][info][cpu] =====================================================================================
```

But `jcmd $(pgrep -n java) PerfCounter.print | grep -E "sun.threads.total_gc_cpu_time"` prints (in this case for ZGC): `sun.threads.total_gc_cpu_time=0`.

Comments
A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/28803 Date: 2025-12-12 21:30:01 +0000
12-12-2025