RFR: 8359110: Log accumulated GC and process CPU time upon VM exit [v17]
Albert Mingkun Yang
ayang at openjdk.org
Thu Jul 3 08:17:44 UTC 2025
On Thu, 3 Jul 2025 07:40:56 GMT, Jonas Norlinder <duke at openjdk.org> wrote:
>> Add support to log CPU cost for GC during VM exit with `-Xlog:gc+cpu`.
>>
>>
>> [2,430s][info][gc,cpu] GC CPU usage: 22,87% (Process: 26,8926s GC: 6,1491s)
>
> Jonas Norlinder has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 27 commits:
>
> - Move call to print_tracing_info
> - Merge branch 'master' into gc_cpu_time
> - Remove static and move string_dedup_cpu_time into elapsed_gc_cpu_time
> - Fixes after @albertnetymk review
> - Change output per discussion
> - Make stop protected, remove integer divison, remove unused method
> - Update closure name
> - vtime -> cpu_time and _vm_vtime -> _vmthread_cpu_time
> - Fixes after review from @stefank
> - Merge branch 'master' of github.com:JonasNorlinder/openjdk_jdk into gc_cpu_time
> - ... and 17 more: https://git.openjdk.org/jdk/compare/c75df634...f9c3aa64
src/hotspot/share/gc/shared/collectedHeap.cpp line 206:
> 204: class CPUTimeThreadClosure : public ThreadClosure {
> 205: private:
> 206: volatile jlong _cpu_time = 0;
There is no need for `volatile`. `gc_threads_do` runs on the calling thread, not on threads we are iterating on.
src/hotspot/share/gc/shared/collectedHeap.cpp line 226:
> 224: if (string_dedup_cpu_time == -1) {
> 225: return -1;
> 226: }
Can probably move this to the very beginning for clearer separation: gc-time comes from three sources -- vmthread, string-dedup and gc-threads.
src/hotspot/share/gc/shared/cpuTimeScope.inline.hpp line 57:
> 55: if (UsePerfData) {
> 56: CPUTimeCounters::get_instance()->update_counter(CPUTimeGroups::CPUTimeType::vm, end);
> 57: }
This class (name/interface) seems fairly generic, but the underlying impl is tightly coupled to vmthread. IOW, one can't use this class other than on vmthread. Maybe this class should be inside vmThread.cpp.
src/hotspot/share/runtime/cpuTimeCounters.hpp line 56:
> 54:
> 55: class CPUTimeCounters: public CHeapObj<mtServiceability> {
> 56: friend class CPUTimeScope;
I wonder if we avoid this. The public APIs should be enough.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25779#discussion_r2182127690
PR Review Comment: https://git.openjdk.org/jdk/pull/25779#discussion_r2182131415
PR Review Comment: https://git.openjdk.org/jdk/pull/25779#discussion_r2182146520
PR Review Comment: https://git.openjdk.org/jdk/pull/25779#discussion_r2182156134
More information about the hotspot-gc-dev
mailing list