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

Thomas Schatzl tschatzl at openjdk.org
Mon Jun 16 08:34:31 UTC 2025


On Fri, 13 Jun 2025 20:11:04 GMT, Jonas Norlinder <duke at openjdk.org> wrote:

>> Add support to log CPU cost for GC during VM exit with `-Xlog:gc`.
>> 
>> 
>> [1.500s][info ][gc] GC CPU cost: 1.75%
>> 
>> 
>> Additionally, detailed information may be retrieved with `-Xlog:gc=trace`
>> 
>> 
>> [1.500s][trace][gc] Process CPU time: 4.945370s
>> [1.500s][trace][gc] GC CPU time: 0.086382s
>> [1.500s][info ][gc] GC CPU cost: 1.75%
>
> Jonas Norlinder has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Add CPU time tracking for string deduplication to log_gc_vtime

Changes requested by tschatzl (Reviewer).

src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp line 166:

> 164:   CollectedHeap::stop();
> 165: }
> 166: 

There is no need to override this method if the only thing it does is calling the super class method.

src/hotspot/share/gc/serial/serialHeap.cpp line 151:

> 149:   CollectedHeap::stop();
> 150: }
> 151: 

There is no need to override this method if the only thing it does is calling the super class method.

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

> 243: 
> 244:   // Stop any onging concurrent work and prepare for exit.
> 245:   virtual void stop() { log_gc_vtime(); }

Please move this implementation into the `.cpp` file to avoid making the `.hpp` file more complicated than needed. It's not performance sensitive at all (or if you really think this is required, into the `.inline.hpp` file).

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

> 256:     _vm_vtime += time;
> 257:   }
> 258: 

Probably better to move into `.inline.hpp` file too.

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

PR Review: https://git.openjdk.org/jdk/pull/25779#pullrequestreview-2930986521
PR Review Comment: https://git.openjdk.org/jdk/pull/25779#discussion_r2149271551
PR Review Comment: https://git.openjdk.org/jdk/pull/25779#discussion_r2149272195
PR Review Comment: https://git.openjdk.org/jdk/pull/25779#discussion_r2149350924
PR Review Comment: https://git.openjdk.org/jdk/pull/25779#discussion_r2149352267


More information about the hotspot-runtime-dev mailing list