Skip to content
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

8281181: Do not use CPU Shares to compute active processor count #7666

Conversation

iklam
Copy link
Member

@iklam iklam commented Mar 2, 2022

This is a simple change (Linux-only) that removes the consideration of Cgroups CPU Shares from the active process count calculation. Of note, this fixes CPU underutilization when Java is executed by Kubernetes without CPU resources limits.

Please see the CSR JDK-8281571 for a detailed discussion of the reasons to make this change.

To err on the side of caution, we added a temporary (and deprecated) VM flag -XX:+UseContainerCpuShares to enable the old behavior. We believe the old behavior is wrong and unnecessary. The plan is to remove the old behavior in JDK 20.

The associated flag, PreferContainerQuotaForCPUCount is also deprecated. Both flags will be obsoleted in JDK 20.

Testing with tiers 1-4, as well as container tests in tier5.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed
  • Change requires a CSR request to be approved

Issues

  • JDK-8281181: Do not use CPU Shares to compute active processor count
  • JDK-8281571: Do not use CPU Shares to compute active processor count (CSR)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/7666/head:pull/7666
$ git checkout pull/7666

Update a local copy of the PR:
$ git checkout pull/7666
$ git pull https://git.openjdk.java.net/jdk pull/7666/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 7666

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/7666.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 2, 2022

👋 Welcome back iklam! 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 Mar 2, 2022

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

  • hotspot-runtime

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-runtime hotspot-runtime-dev@openjdk.org label Mar 2, 2022
@iklam
Copy link
Member Author

iklam commented Mar 2, 2022

/label remove hotspot-runtime
/label add hotspot

@openjdk openjdk bot removed the hotspot-runtime hotspot-runtime-dev@openjdk.org label Mar 2, 2022
@openjdk
Copy link

openjdk bot commented Mar 2, 2022

@iklam
The hotspot-runtime label was successfully removed.

@openjdk openjdk bot added the hotspot hotspot-dev@openjdk.org label Mar 2, 2022
@openjdk
Copy link

openjdk bot commented Mar 2, 2022

@iklam
The hotspot label was successfully added.

@iklam iklam marked this pull request as ready for review March 2, 2022 21:05
@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 2, 2022
@mlbridge
Copy link

mlbridge bot commented Mar 2, 2022

Webrevs

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

Hi Ioi,

Generally looks good. A couple of nits below.

The deprecated flags should be added to the VMDeprecatedOptions test.

Thanks,
David

int share = cpu_shares();

// It's not a good idea to use cpu_shares() to limit the number
// of CPUs used by the JVM. See JDK-8281571.
Copy link
Member

Choose a reason for hiding this comment

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

I suggest using JDK-8281181 rather than the CSR issue.

@@ -100,6 +100,11 @@ private static void testComboWithCpuSets() throws Exception {
String cpuSetStr = CPUSetsReader.readFromProcStatus("Cpus_allowed_list");
System.out.println("cpuSetStr = " + cpuSetStr);

// OLD = use the deprecated -XX:+UseContainerCpuShares flag, which
// will be removed in the next JDK release. See JDK-8281571.
Copy link
Member

Choose a reason for hiding this comment

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

I suggest using JDK-8281181 rather than the CSR issue.

@iklam
Copy link
Member Author

iklam commented Mar 3, 2022

Hi Ioi,

Generally looks good. A couple of nits below.

The deprecated flags should be added to the VMDeprecatedOptions test.

Thanks, David

Hi David, thanks for the review. I've updated the patch as you suggested.

Copy link
Contributor

@jerboaa jerboaa left a comment

Choose a reason for hiding this comment

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

LGTM

@openjdk
Copy link

openjdk bot commented Mar 3, 2022

@iklam 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:

8281181: Do not use CPU Shares to compute active processor count

Reviewed-by: dholmes, sgehwolf

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 35 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 openjdk bot added the ready Pull request is ready to be integrated label Mar 3, 2022
Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

Updates look good.

Please file an issue to obsolete these flags in JDK 20 (they will be expired en-masse in JDK 21).

Thanks,
David

@iklam
Copy link
Member Author

iklam commented Mar 4, 2022

Updates look good.

Please file an issue to obsolete these flags in JDK 20 (they will be expired en-masse in JDK 21).

Thanks, David

I filed https://bugs.openjdk.java.net/browse/JDK-8282684

Thanks

@iklam
Copy link
Member Author

iklam commented Mar 4, 2022

Thanks to @dholmes-ora and @jerboaa for the review.
/integrate

@openjdk
Copy link

openjdk bot commented Mar 4, 2022

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

  • 9c817d3: 8015854: [macosx] JButton's HTML ImageView adding unwanted padding
  • 733c790: 8282081: java.time.DateTimeFormatter: wrong definition of symbol F
  • f9f9c0a: 8252769: Warn in configure if git config autocrlf has invalid value
  • 603050b: 8282661: [BACKOUT] ByteBufferTest.java: replace endless recursion with RuntimeException in void ck(double x, double y)
  • 5247153: 8282615: G1: Fix some includes
  • a584c90: 8282573: ByteBufferTest.java: replace endless recursion with RuntimeException in void ck(double x, double y)
  • d5e8e52: 8282532: Allow explicitly setting build platform alongside --openjdk-target
  • b383780: 8282343: Create a regression test for JDK-4518432
  • b629782: 8279886: C1: Turn off SelectivePhiFunctions in presence of irreducible loops
  • 7e1c67d: 8282608: RawNativeLibraryImpl can't be passed to NativeLibraries::findEntry0
  • ... and 44 more: https://git.openjdk.java.net/jdk/compare/e4d9fc811e0ef0eb9b097e06525a1183445d8d79...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Mar 4, 2022

@iklam Pushed as commit e07fd39.

💡 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 hotspot-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

4 participants