RFR: 8354727: CompilationPolicy creates too many compiler threads when code cache space is scarce [v3]

Manuel Hässig mhaessig at openjdk.org
Fri Jun 13 09:54:11 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 with a new target base due to a merge or a rebase. The pull request now contains three commits:

 - Fix inadvertantly removed header
   
   Co-developed-by: Damon Fenacci <dfenacci at openjdk.org>
 - Respect NonNMethodCodeHeapSize during ergonomic compiler count selection
 - Correctly calculate the compiler buffer size
   
   Co-authored-by: Aleksey Shipilev <shade at openjdk.org>

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

Changes: https://git.openjdk.org/jdk/pull/25770/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=25770&range=02
  Stats: 11 lines in 1 file changed: 8 ins; 0 del; 3 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