JDK-8359110 : Log accumulated GC and process CPU time upon VM exit
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: gc
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2025-06-10
  • Updated: 2025-07-04
  • Resolved: 2025-07-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 26
26 masterFixed
Related Reports
Blocks :  
Blocks :  
Relates :  
Description
Currently there is no easy way to get the accumulative CPU time spent on GC activities. While e.g. G1 indeed samples GC time on each cycle, these numbers will be incorrect if GC cycle frequency is high, which is the case of multiples close to the minimum heap. The numbers are incorrect since we rely on the kernel to update the underlying values which only happens so often. Additionally since the precision is on the millisecond level it is also possible to observe cycles where we approximate the GC CPU time to 0, e.g.

[1.603s][info][gc,cpu] GC(60) User=0.00s Sys=0.00s Real=0.00s
[1.642s][info][gc,cpu] GC(61) User=0.00s Sys=0.00s Real=0.00s
[1.680s][info][gc,cpu] GC(62) User=0.00s Sys=0.00s Real=0.00s
[1.682s][info][gc,cpu] GC(63) User=0.00s Sys=0.00s Real=0.00s
[1.682s][info][gc,cpu] GC(63) User=0.00s Sys=0.00s Real=0.00s

This leads to inaccurate accumulative GC CPU time as error delta adds up.
We could fetch CPU time for GC related threads upon VM exit. This will assist a user/developer to understand the CPU cost for GC and may aid users setting a heap size.

JDK-8315149 introduced thread CPU time sampling in the VM thread on completed operation. This patch will add a thread CPU time sampling for GC related VM operations before executing an operation to be able to measure the CPU time. This will allow us to account for e.g. Serial that only uses the VM thread, as-well as improving accounting for other GCs.
Comments
Changeset: 56ebb8c1 Branch: master Author: Jonas Norlinder <jonas.norlinder@oracle.com> Committer: Thomas Schatzl <tschatzl@openjdk.org> Date: 2025-07-04 10:16:55 +0000 URL: https://git.openjdk.org/jdk/commit/56ebb8c1b936e5a4c14486153c9f60df705095ad
04-07-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/25779 Date: 2025-06-12 11:28:14 +0000
12-06-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/25724 Date: 2025-06-10 13:24:37 +0000
10-06-2025