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

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


On Wed, 23 Jul 2025 07:00:46 GMT, Man Cao <manc at openjdk.org> wrote:

> However, it could be challenging in some environments. E.g. a background controller process that periodically runs taskset to change CPU affinity mask for the Java process, leading to os::active_processor_count() returning variable values.

As bad as it sounds, this is already basically an unsupported use case. G1 heuristic will be screwed already (actually lots of ergonomics/predictions do not even very well support wildly changing values returned from ergonomic thread sizing, i.e. self-inflicted thread number changes).

Use the `ActiveProcessorCount` option with an average or so.

I do not think it is the purpose of this change to try to go to great lengths to start supporting this use case. We can consider it though, but it should not prevent progress imo.

> Another scenario is that the Java process runs in a CPU-constraint container, but for some reasons has to run with -XX:-UseContainerSupport. Then all of os::active_processor_count(), ConcGCThreads, ParallelGCThreads could be much higher than the max # of available CPU cores.

We can't do much about this (bad configuration), and is already problematic wrt even to initial thread sizing.

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

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


More information about the hotspot-gc-dev mailing list