-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
8269851: OperatingSystemMXBean getProcessCpuLoad reports incorrect process cpu usage in containers #4702
Conversation
…ocess cpu usage in containers
👋 Welcome back xpbob! A progress list of the required criteria for merging this PR into |
/issue add JDK-8269851 |
@xpbob This issue is referenced in the PR title - it will now be updated. |
getProcessCpuLoad return jvm cpu load。 expected |
Webrevs
|
Why did you create a new PR ?? |
bug description changed。 |
src/jdk.management/unix/classes/com/sun/management/internal/OperatingSystemImpl.java
Show resolved
Hide resolved
Hi Bob, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In HotSpot, CPU usage for JVM would be calculated at get_jvm_tickes()
in os_perf_linux.cpp . It refers /proc/self/stat
- should we refer it in same way?
I discussed about similar issue in #4299 , then we came to an agreement that we should refactor that HotSpot and JMX should share the code. Of course you can fix JMX only in this PR, but it still uses different implementation from HotSpot. I prefer to fix it in code consolidation between HotSpot and JMX.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This patch seems fine in principle, but I don't like the duplication. Right now, getProcessUsageDividesTotal()
and getUsageDividesTotal()
look almost the same, but use different fields to set. Perhaps pass a parameter whether or not it's a system/process load request and use the different setters accordingly. Same duplication between getCpuLoad()
and getProcessCpuLoad()
. The main difference seems to be how usageNanos
are being retrieved.
Yes, we need a bug to track this work (or at least decide on a plan of action - if any). I wouldn't conflate this into this bug, though as it's not clear whether or not JFR/thread dumps should report container values. I'll try to create a bug for this consolidation effort today. |
Let me revise this. It looks like imposing CPU limits via cpuset-cpus would go down a path which won't have this fixed with the current patch. |
use (getProcessCpuLoad0() * totalCPUs / containerCPUs) for CPU limits via cpuset-cpus |
Mailing list message from David Holmes on jmx-dev: On 7/07/2021 2:37 pm, xpbob wrote:
There was no reason to create a new PR. David |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update. getProcessCpuLoad()
and getCpuLoad()
looks way too similar to me. Is there a way to make them more generic and do the process vs. system paths as needed? I think there is.
use getCpuLoadWithTarget for process and system |
Thanks. We are getting there. I've proposed a PR to your branch which makes this a bit easier to read: If you merge that it'll show up in this PR. |
Thank you so much @jerboaa . Code has been merged.
|
/Contributor add @jerboaa |
@xpbob |
/test |
https://github.com/jerboaa/jdk/actions/runs/1026610314 is a pre-integration run of this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except for the missing comments in the new code blocks this looks good to me.
src/jdk.management/unix/classes/com/sun/management/internal/OperatingSystemImpl.java
Show resolved
Hide resolved
src/jdk.management/unix/classes/com/sun/management/internal/OperatingSystemImpl.java
Show resolved
Hide resolved
@xpbob 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:
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 304 new commits pushed to the
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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@YaSuenag, @jerboaa) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still looks good.
May I get a second review for this change? Thanks. |
/integrate |
Will sponsor it tomorrow if there is no objection. |
/sponsor |
Going to push as commit 25f00d7.
Your commit was automatically rebased without conflicts. |
@DamonFool @xpbob Pushed as commit 25f00d7. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
…ocess cpu usage in containers
Progress
Issue
Reviewers
Contributors
<sgehwolf@openjdk.org>
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/4702/head:pull/4702
$ git checkout pull/4702
Update a local copy of the PR:
$ git checkout pull/4702
$ git pull https://git.openjdk.java.net/jdk pull/4702/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 4702
View PR using the GUI difftool:
$ git pr show -t 4702
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/4702.diff