RFR: 8359348: G1: Improve cpu usage measurements for heap sizing [v3]

Thomas Schatzl tschatzl at openjdk.org
Thu Jul 24 10:28:54 UTC 2025


On Thu, 24 Jul 2025 09:46:28 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:

>> src/hotspot/share/gc/g1/g1Policy.cpp line 678:
>> 
>>> 676:   double cur_gc_cpu_time_ms = _g1h->elapsed_gc_cpu_time() * MILLIUNITS;
>>> 677: 
>>> 678:   double concurrent_gc_cpu_time_ms = cur_gc_cpu_time_ms - prev_gc_cpu_pause_end_ms;
>> 
>> `CollectedHeap::elapsed_gc_cpu_time()` includes  `_vmthread_cpu_time` and `string_dedup_cpu_time`. Should we exclude VM threads and StringDedup threads' CPU time from `concurrent_gc_cpu_time_ms`? Otherwise non-GC activities could affect G1's heap sizing decisions.
>
> VMThread cpu time only contains VM thread cpu time for GC VM operations; string deduplication is a GC/memory management activity.

Another issue seems to be that since both `record_pause_start()` and `record_pause()` are called for all pauses. It seems that this implementation only considers the concurrent CPU usage between Remark/Cleanup and Young pauses as G1 currently only resizes at Young collections.

The bulk of concurrent work is from Young -> Remark and Remark -> Cleanup though. If e.g. all of the concurrent cycles occurs between two Young GCs, that whole concurrent cycle seems to be lost in the calculation (or at least parts of the concurrent CPU usage)?

Or am I missing something?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26351#discussion_r2228117822


More information about the hotspot-gc-dev mailing list