Skip to content

8356000: C1/C2-only modes use 2 compiler threads on low CPU count machines #24972

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

shipilev
Copy link
Member

@shipilev shipilev commented Apr 30, 2025

There is an unfortunate limitation with default tiered policy that we would have at least 2 threads on 1 CPU machine: 1 thread for C1, and 1 thread for C2.

But if we select C1-only or C2-only modes, we also get 2 compiler threads, for which we have no good reason. These threads would just step on each other toes. The fix changes the behavior for 1..3 CPU hosts in C1/C2-only configurations, by using 1 thread instead of 2 threads. The change for 1 CPU config is what we really need. The change in 2..3 CPU configs is an additional effect, but I think it is still good not to use 100%/66% of the CPUs in those configurations as well.

$ for I in `seq 1 8`; do build/linux-x86_64-server-release/images/jdk/bin/java \
  -XX:-TieredCompilation -XX:ActiveProcessorCount=${I} \
  -XX:+PrintFlagsFinal 2>&1 | grep "CICompilerCount "; done

# Before
     intx CICompilerCount                          = 2
     intx CICompilerCount                          = 2
     intx CICompilerCount                          = 2
     intx CICompilerCount                          = 3
     intx CICompilerCount                          = 3
     intx CICompilerCount                          = 3
     intx CICompilerCount                          = 3
     intx CICompilerCount                          = 4

# After
     intx CICompilerCount                          = 1
     intx CICompilerCount                          = 1
     intx CICompilerCount                          = 1
     intx CICompilerCount                          = 3
     intx CICompilerCount                          = 3
     intx CICompilerCount                          = 3
     intx CICompilerCount                          = 3
     intx CICompilerCount                          = 4

It is a minor bug in CompilationPolicy::initialize, but it gets in the way studying Leyden in tight CPU scenarios.

Additional testing:

  • New regression test passes with the fix, fails without it
  • GHA

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-8356000: C1/C2-only modes use 2 compiler threads on low CPU count machines (Bug - P4)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 24972

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 30, 2025

👋 Welcome back shade! 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 Apr 30, 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 Apr 30, 2025
@openjdk
Copy link

openjdk bot commented Apr 30, 2025

@shipilev 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.

@mlbridge
Copy link

mlbridge bot commented Apr 30, 2025

Webrevs

}
assert((!c1_only && !c2_only) || count <= active_cpus, "Too many threads: %d", count);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should it be the general rule: don't create more compiler threads than available cpus?

Copy link
Contributor

Choose a reason for hiding this comment

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

Except when specified on command line with -XX:CICompilerCount=n.
Actually your changes does not take this flag into account.

@shipilev shipilev changed the title 8356000: C1/C2-only modes use 2 compiler threads on 1 CPU machine 8356000: C1/C2-only modes use 2 compiler threads on low CPU count machines May 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-compiler [email protected] rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

2 participants