Skip to content

Conversation

@mhaessig
Copy link
Contributor

@mhaessig mhaessig commented Jun 12, 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,NonNMethodHeapSizeis 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

  • GHA
  • tier1 and tier2 plus Oracle internal testing on our supported platforms
  • tier1 with a manually fixed core count of 288 (this reproduced the problem before the fix)

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Integration blocker

 ⚠️ Dependency #25791 must be integrated first

Issue

  • JDK-8354727: CompilationPolicy creates too many compiler threads when code cache space is scarce (Bug - P4)

Reviewers

Contributors

  • Aleksey Shipilev <shade@openjdk.org>

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25770/head:pull/25770
$ git checkout pull/25770

Update a local copy of the PR:
$ git checkout pull/25770
$ git pull https://git.openjdk.org/jdk.git pull/25770/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 25770

View PR using the GUI difftool:
$ git pr show -t 25770

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25770.diff

Using Webrev

Link to Webrev Comment

@mhaessig
Copy link
Contributor Author

/contributor add @shipilev

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 12, 2025

👋 Welcome back mhaessig! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Jun 12, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 12, 2025
@openjdk
Copy link

openjdk bot commented Jun 12, 2025

@mhaessig
Contributor Aleksey Shipilev <shade@openjdk.org> successfully added.

@openjdk
Copy link

openjdk bot commented Jun 12, 2025

@mhaessig The following label will be automatically applied to this pull request:

  • hotspot-compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Jun 12, 2025
@mlbridge
Copy link

mlbridge bot commented Jun 12, 2025

Webrevs

Copy link
Contributor

@dafedafe dafedafe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this @mhaessig.
I guess the issue cannot happen if NonNMethodCodeHeapSize is not given as a flag as it will be dynamically adapted to the number of compiler threads created, right?

@mhaessig
Copy link
Contributor Author

Thank you for having a look @dafedafe!

I guess the issue cannot happen if NonNMethodCodeHeapSize is not given as a flag as it will be dynamically adapted to the number of compiler threads created, right?

That is right. In this case, the heuristics in CodeCache::initialize_heaps() take over.

Copy link
Contributor

@dafedafe dafedafe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks @mhaessig.

@mhaessig mhaessig changed the base branch from master to pr/25791 June 13, 2025 09:27
@openjdk
Copy link

openjdk bot commented Jun 13, 2025

@mhaessig this pull request can not be integrated into pr/25791 due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout JDK-8354727-policy
git fetch https://git.openjdk.org/jdk.git pr/25791
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge pr/25791"
git push

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Jun 13, 2025
mhaessig and others added 3 commits June 13, 2025 11:29
Co-authored-by: Aleksey Shipilev <shade@openjdk.org>
Co-developed-by: Damon Fenacci <dfenacci@openjdk.org>
@mhaessig mhaessig force-pushed the JDK-8354727-policy branch from b62ef8a to 98a8107 Compare June 13, 2025 09:47
@openjdk
Copy link

openjdk bot commented Jun 13, 2025

@mhaessig Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information.

@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label Jun 13, 2025
@mhaessig
Copy link
Contributor Author

I made this dependent on #25791 and rebased onto it.

@mhaessig mhaessig marked this pull request as draft June 13, 2025 12:02
@openjdk openjdk bot removed the rfr Pull request is ready for review label Jun 13, 2025
@mhaessig mhaessig closed this Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-compiler hotspot-compiler-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

2 participants