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

Thomas Schatzl tschatzl at openjdk.org
Wed Aug 27 08:18:47 UTC 2025


On Tue, 26 Aug 2025 14:50:50 GMT, Ivan Walulya <iwalulya at openjdk.org> wrote:

>> Hi,
>> 
>> Please review this patch which takes into account the impact of concurrent GC activity on mutator threads when computing the time spent on GC activity in a time interval. Previously, only the GC pause times were considered, and the overhead imposed by concurrent GC worker threads was not included.
>> 
>> With this change, we now estimate the impact of concurrent GC by dividing `elapsed_gc_cpu_time` by the number of CPUs. This provides an approximation of the additional time attributable to GC activity, assuming a fair CPU resource sharing.  Although this method does not account for contention on other shared resources (such as memory bandwidth or caches), it offers a reasonable estimate for most scenarios.
>> 
>> Testing: Tier 1
>
> Ivan Walulya has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 15 commits:
> 
>  - Albert Review + Merge
>  - Merge remote-tracking branch 'upstream/master' into ConcCPUImpact
>  - remove unused
>  - Merge remote-tracking branch 'upstream/master' into ConcCPUImpact
>  - accumlate concurrent_gc_impact_time
>  - Merge remote-tracking branch 'upstream/master' into ConcCPUImpact
>  - cleanup after merge
>  - Merge remote-tracking branch 'upstream/master' into ConcCPUImpact
>  - Merge branch 'NormalizeTiming' into ConcCPUImpact
>  - Thomas suggestion
>  - ... and 5 more: https://git.openjdk.org/jdk/compare/3641c32c...bf349d2d

src/hotspot/share/gc/g1/g1Policy.cpp line 670:

> 668: 
> 669:   double prev_gc_cpu_pause_end_ms = _analytics->gc_cpu_time_pause_end_ms();
> 670:   double cur_gc_cpu_time_ms = (double) CPUTimeUsage::GC::gc_threads() / NANOSECS_PER_MILLISEC;

Suggestion:

  double cur_gc_cpu_time_ms = (double)CPUTimeUsage::GC::gc_threads() / NANOSECS_PER_MILLISEC;

src/hotspot/share/gc/g1/g1Policy.cpp line 1380:

> 1378:   update_time_to_mixed_tracking(gc_type, start, end);
> 1379: 
> 1380:   double elapsed_gc_cpu_time = CPUTimeUsage::GC::gc_threads() / NANOSECS_PER_MILLISEC;

I think this should be:
Suggestion:

  double elapsed_gc_cpu_time = (double)CPUTimeUsage::GC::gc_threads() / NANOSECS_PER_MILLISEC;

to avoid rounding.

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

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


More information about the hotspot-gc-dev mailing list