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

Stefan Karlsson stefank at openjdk.org
Mon Jun 30 13:57:43 UTC 2025


On Mon, 30 Jun 2025 13:35:23 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 with a new target base due to a merge or a rebase. The pull request now contains 18 commits:
> 
>  - Merge branch 'master' of github.com:JonasNorlinder/openjdk_jdk into gc_cpu_time
>  - Implement CollectedHeap::before_exit() as suggested by @stefank
>  - Remove incorrect is_gc_operation call after rebase
>  - More clean up, remove virtual
>  - Fixes after feedback from @stefank
>  - Remove extra whitespace
>  - operation_is_gc -> is_gc_operation per @stefank suggestion
>  - Only sample if needed
>  - Remove explicit super call and minor fixes
>  - Add CPU time tracking for string deduplication to log_gc_vtime
>  - ... and 8 more: https://git.openjdk.org/jdk/compare/aa191119...0993931f

I've listed a couple more nits.

Given that JDK-8274051 has now been integrated should the os::elapsedVTime be removed from this patch?

I know that we talked about the vtime name earlier. Should we still use the `vtime` name now that we have removed elapsedVTime?

src/hotspot/share/gc/shared/vtimeScope.hpp line 37:

> 35:   bool          _enabled;
> 36:   bool          _is_gc_operation;
> 37:   Thread*       _thread;

Suggestion:

  jlong   _start;
  bool    _enabled;
  bool    _is_gc_operation;
  Thread* _thread;

src/hotspot/share/gc/shared/vtimeScope.inline.hpp line 44:

> 42: 
> 43: inline VTimeScope::~VTimeScope() {
> 44:   if (!_enabled) return;

This is a style that most HotSpot GC devs try to avoid.
Suggestion:

  if (!_enabled) {
    return;
  }

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

PR Review: https://git.openjdk.org/jdk/pull/25779#pullrequestreview-2971280145
PR Review Comment: https://git.openjdk.org/jdk/pull/25779#discussion_r2175108401
PR Review Comment: https://git.openjdk.org/jdk/pull/25779#discussion_r2175113990


More information about the hotspot-gc-dev mailing list