Skip to content

Conversation

@mhaessig
Copy link
Contributor

@mhaessig mhaessig commented Jun 18, 2025

Running

java -XX:+SegmentedCodeCache -XX:ReservedCodeCacheSize=10M -XX:NonNMethodCodeHeapSize=6M \
     -XX:ProfiledCodeHeapSize=5M -XX:NonProfiledCodeHeapSize=5M -version

on a machine with more than 285 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 (especially on a debug build) and causes a check changed in #17244 to fail. That check was changed to check that all compiler buffers fit into the NonNMethodCodeHeap instead of the NonNMethodCodeHeap having at least a size of CodeCacheMinimumUseSpace.

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 buffer size available for compilers buffers in the calculation of the maximum number of compiler threads instead of ReservedCodeCacheSize. Therefore, the check failing in the explanation above can never fail because we set the number of compiler threads only so high that they will always fit into the NonNMethodCodeHeap.

This change changes how many compiler threads are created by the CICompilerCount ergonomic. For the default value NonNMethodCodeHeapSize=5Mthis limit is 24 compiler threads on a system 285 cores or more for product builds and 20 threads for debug builds on a system with 145 cores or more.

Testing

  • Github Actions
  • tier1 through tier3 plus Oracle internal testing on our supported platforms

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

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/25872/head:pull/25872
$ git checkout pull/25872

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 25872

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 18, 2025

👋 Welcome back mhaessig! A progress list of the required criteria for merging this PR into pr/25791 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 18, 2025

@mhaessig This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8354727: CompilationPolicy creates too many compiler threads when code cache space is scarce

Co-authored-by: Aleksey Shipilev <shade@openjdk.org>
Reviewed-by: kvn, shade

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 4 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk
Copy link

openjdk bot commented Jun 18, 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 18, 2025
@mhaessig
Copy link
Contributor Author

/contributor add @shipilev

@openjdk
Copy link

openjdk bot commented Jun 18, 2025

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

@mhaessig mhaessig marked this pull request as ready for review June 18, 2025 14:15
@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 18, 2025
@mlbridge
Copy link

mlbridge bot commented Jun 18, 2025

Webrevs

@openjdk-notifier openjdk-notifier bot changed the base branch from pr/25791 to master June 18, 2025 18:10
@openjdk-notifier
Copy link

The parent pull request that this pull request depends on has now been integrated and the target branch of this pull request has been updated. This means that changes from the dependent pull request can start to show up as belonging to this pull request, which may be confusing for reviewers. To remedy this situation, simply merge the latest changes from the new target branch into this pull request by running commands similar to these in the local repository for your personal fork:

git checkout JDK-8354727-policy
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# if there are conflicts, follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk
Copy link

openjdk bot commented Jun 18, 2025

@mhaessig this pull request can not be integrated into master 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 master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Jun 18, 2025
@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label Jun 18, 2025
@mhaessig mhaessig marked this pull request as draft June 18, 2025 18:59
@openjdk openjdk bot removed the rfr Pull request is ready for review label Jun 18, 2025
@mhaessig
Copy link
Contributor Author

The changes to the files src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.(c|h)pp are artifacts from merge conflicts.

@mhaessig mhaessig marked this pull request as ready for review June 19, 2025 09:16
@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 19, 2025
@sendaoYan
Copy link
Member

This PR fix the failure https://bugs.openjdk.org/browse/JDK-8359685 in linux-x64 & (core number = 256)

@vnkozlov
Copy link
Contributor

The changes to the files src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.(c|h)pp are artifacts from merge conflicts.

This undid cf78925 changes. Something wrong was with merge.

@vnkozlov
Copy link
Contributor

Changes looks fine.

@mhaessig
Copy link
Contributor Author

This undid cf78925 changes. Something wrong was with merge.

I fixed that in the latest commit. Thank you for pointing it out.

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

Good.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 19, 2025
@sendaoYan
Copy link
Member

I think this PR ready to integrate

@shipilev
Copy link
Member

If you merge from current master, windows builds are going to be fixed as well.

@mhaessig
Copy link
Contributor Author

Thank you for your reviews!

/integrate

@openjdk
Copy link

openjdk bot commented Jun 25, 2025

Going to push as commit f2ef809.
Since your change was applied there have been 4 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jun 25, 2025
@openjdk openjdk bot closed this Jun 25, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jun 25, 2025
@openjdk
Copy link

openjdk bot commented Jun 25, 2025

@mhaessig Pushed as commit f2ef809.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

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 integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

5 participants