RFR: 8359348: G1: Improve cpu usage measurements for heap sizing [v3]
Thomas Schatzl
tschatzl at openjdk.org
Mon Jul 28 11:29:57 UTC 2025
On Mon, 28 Jul 2025 10:20:02 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:
>> src/hotspot/share/gc/g1/g1Analytics.cpp line 174:
>>
>>> 172: // caches, therefore underestimate the impact of the concurrent GC activity on mutator threads.
>>> 173: uint num_cpus = (uint)os::active_processor_count();
>>> 174: num_cpus = MIN2(num_cpus, MAX2(ConcGCThreads, ParallelGCThreads));
>>
>> A minor issue is that `UseDynamicNumberOfGCThreads` may not activate all `ConcGCThreads`. I think it is acceptable the wall-clock time "lost" by mutator threads is a best-effort approximation anyway.
>
> Fwiw, G1 has both `ConcGCThreads` (for marking; 1/4th of `ParallelGCThreads`) and `ConcRefinementThreads` (for refinement; equal in count with `ParallelGCThreads`) which are active at the same time.
> Not sure if only using `ConcGCThreads` (`ParallelGCThreads`?) is appropriate for this calculation.
An alternative would be to consider concurrent cpu usage (`concurrent-cpu-usage`) as fraction of total cpu usage during the mutator phase (`total-cpu-usage-during-mutator`), and consider gc pause cpu usage as 100% total cpu usage during the pause (where `gc-pause-cpu-usage = #active processors * pause-duration`).
Ie. in total
gc-time-ratio = (concurrent-cpu-usage + gc-pause-cpu-usage) / (total-cpu-usage-during-mutator + gc-pause-cpu-usage)
The dividend is G1 total cpu usage from end of previous GC to end of next GC, the divisor total cpu usage during the same time frame.
It may be a bit problematic wrt to changing active processors but it seems preferable to guessing the number of threads used.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26351#discussion_r2235974815
More information about the hotspot-gc-dev
mailing list