RFR: 8359110: Log accumulated GC and process CPU time upon VM exit [v14]

Albert Mingkun Yang ayang at openjdk.org
Wed Jul 2 11:26:49 UTC 2025


On Tue, 1 Jul 2025 12:03:08 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 incrementally with one additional commit since the last revision:
> 
>   Change output per discussion

src/hotspot/share/gc/shared/collectedHeap.cpp line 211:

> 209: public:
> 210:   virtual void do_thread(Thread* thread) {
> 211:     Atomic::add(&_cpu_time, os::thread_cpu_time(thread));

Should we check for `-1` here?

src/hotspot/share/gc/shared/collectedHeap.cpp line 630:

> 628:     double process_cpu_time = os::elapsed_process_cpu_time();
> 629:     double gc_cpu_time = elapsed_gc_cpu_time();
> 630:     double string_dedup_cpu_time = UseStringDeduplication ? (double)os::thread_cpu_time((Thread*)StringDedup::_processor->_thread) / NANOSECS_PER_SEC : 0;

If we consider stringdedup as gc-time, should this line be inlined to `elapsed_gc_cpu_time`?

src/hotspot/share/gc/shared/collectedHeap.cpp line 634:

> 632:     if (process_cpu_time == -1 || gc_cpu_time == -1 || string_dedup_cpu_time == -1) {
> 633:       return;
> 634:     }

Should there be a warning-log here?

src/hotspot/share/gc/shared/collectedHeap.hpp line 135:

> 133:   NOT_PRODUCT(volatile size_t _promotion_failure_alot_gc_number;)
> 134: 
> 135:   static jlong _vmthread_cpu_time;

I wonder if it's more natural to make it non-static.

src/hotspot/share/gc/shared/collectedHeap.hpp line 212:

> 210: 
> 211:   // Stop any onging concurrent work and prepare for exit.
> 212:   virtual void stop() = 0;

Why `= 0` instead of `{}` as before?

src/hotspot/share/gc/z/zCollectedHeap.cpp line 25:

> 23: 
> 24: #include "classfile/classLoaderData.hpp"
> 25: #include "gc/shared/collectedHeap.inline.hpp"

Seems unneeded.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25779#discussion_r2179799665
PR Review Comment: https://git.openjdk.org/jdk/pull/25779#discussion_r2179801486
PR Review Comment: https://git.openjdk.org/jdk/pull/25779#discussion_r2179791109
PR Review Comment: https://git.openjdk.org/jdk/pull/25779#discussion_r2179805696
PR Review Comment: https://git.openjdk.org/jdk/pull/25779#discussion_r2179792124
PR Review Comment: https://git.openjdk.org/jdk/pull/25779#discussion_r2179781501


More information about the hotspot-gc-dev mailing list