RFR: 8354727: CompilationPolicy creates too many compiler threads when code cache space is scarce
Manuel Hässig
mhaessig at openjdk.org
Tue Jun 17 08:03:08 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 check updated in #17244 to fail that should ensure that `NonNMethodCodeHeapSize` is at least `CodeCacheMinimumUseSpace` plus the size of all `CICompilerCount` compiler buffers. This is stronger than before #17244 where this check merely required `NonNMethodCodeHeapSize >= CodeCacheMinimumUseSpace` due to the fact that compiler buffers can also use the rest of the code cache if the non-nmethod heap is not sufficient.
# Change Rationale
This PR reverts the failing check to ensuring `NonNMethodCodeHeapSize >= CodeCacheMinimumUseSpace` since the computation of the ergonomic `CICompilerCount` in `CompilationPolicy::initialize()` does not support the assumption that all compiler buffers must always fit inside the non-nmethod code heap.
This change required to adjust a test, because with the weaker check, it is currently not possible to trigger it from the commandline.
# Testing
- [x] [Github Actions](https://github.com/mhaessig/jdk/actions/runs/15681197877)
- [x] tier1 and tier2 plus some Oracle internal testing
-------------
Commit messages:
- Fix test for new semantics
- Set minimum size for non-nmethod code heap to CodeCacheMinimumUseSize
Changes: https://git.openjdk.org/jdk/pull/25830/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=25830&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8354727
Stats: 2 lines in 2 files changed: 0 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/25830.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/25830/head:pull/25830
PR: https://git.openjdk.org/jdk/pull/25830
More information about the hotspot-compiler-dev
mailing list