RFR: 8354727: CompilationPolicy creates too many compiler threads when code cache space is scarce [v2]
Manuel Hässig
mhaessig at openjdk.org
Thu Jun 12 09:35:19 UTC 2025
> # Issue Summary
>
> Running
>
> java -XX:+SegmentedCodeCache -XX:ReservedCodeCacheSize=10M -XX:NonNMethodCodeHeapSize=6M \
> -XX:ProfiledCodeHeapSize=5M -XX:NonProfiledCodeHeapSize=5M -version
>
> on a machine with more than 255 cores, this would fail with the message that the specified `NonNMethodCodeHeapSize` is too small to fit all compiler buffers (instead of failing because the sum of the heaps is larger than the `ReservedCodeCacheSize`). Hence, the calculated compiler count is too high. This is due to `CompilationPolicy::initialize()` checking how many compiler buffers fit into the `ReservedCodeCacheSize`. However, in the case above, this is significantly larger than `NonNMethodCodeHeapSize` and causes a new check introduced in #17244 to fail.
>
> # Changes
>
> This PR fixes the calculation of the `CICompilerCount` ergonomic. Firstly, @shipilev kindly provided a fix for the compiler buffer size used in the calculation is also correct if we only have C2. Secondly,`NonNMethodHeapSize`is used as the maximum buffers size available for compilers buffers instead of `ReservedCodeCacheSize` if it was provided as a commandline flag.
>
> It might be debatable if this is the correct fix, since the `NonNMethodHeap` can spill into the other heaps if it is too small. However, I am of the opinion that if the `NonNMethodHeapSize` is explicitly specified, then the compiler count should be calculated accordingly.
>
> # Testing
>
> - [x] [GHA](https://github.com/mhaessig/jdk/actions/runs/15603409859)
> - [x] tier1 and tier2 plus Oracle internal testing on our supported platforms
> - [x] tier1 with a manually fixed core count of 288 (this reproduced the problem before the fix)
Manuel Hässig has updated the pull request incrementally with one additional commit since the last revision:
Fix inadvertantly removed header
Co-developed-by: Damon Fenacci <dfenacci at openjdk.org>
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/25770/files
- new: https://git.openjdk.org/jdk/pull/25770/files/8d1b4f79..b62ef8ab
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=25770&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=25770&range=00-01
Stats: 1 line in 1 file changed: 1 ins; 0 del; 0 mod
Patch: https://git.openjdk.org/jdk/pull/25770.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/25770/head:pull/25770
PR: https://git.openjdk.org/jdk/pull/25770
More information about the hotspot-compiler-dev
mailing list