-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
JDK-8281274: deal with ActiveProcessorCount in os::Linux::print_container_info #7354
Conversation
👋 Welcome back mbaesken! A progress list of the required criteria for merging this PR into |
Webrevs
|
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.
Looks fine.
While looking at this I found that the default for ActiveProcessorCount is -1. The VM only reacts to this flag if it is >0. So, what is 0? The java man page is not saying. Maybe the default should just be 0 to be consistent.
@MBaesken 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 39 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. ➡️ To integrate this PR with the above commit message to the |
src/hotspot/os/linux/os_linux.cpp
Outdated
@@ -2174,7 +2174,12 @@ bool os::Linux::print_container_info(outputStream* st) { | |||
int i = OSContainer::active_processor_count(); | |||
st->print("active_processor_count: "); | |||
if (i > 0) { | |||
st->print_cr("%d", i); | |||
if (ActiveProcessorCount > 0) { | |||
st->print_cr("%d, but overwritten by flag ActiveProcessorCount: %d", |
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 will print the same number (processor count) twice. I'd suggest to only add a blurb like " overridden by -XX:ActiveProcessorCount"
in case the flag is set and not print the blurb otherwise.
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.
Asserting the new output in the jtreg test would be good to have too.
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 format is fine me with me. You want to see both the container processor count and the actual count being used.
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.
Hi Severin , I adjusted the output following your suggestion (David, in case ActiveProcessorCount is set on the command line it is printed as well , see Arguments::print_summary_on , probably that's why Severin does not want it here.
Regarding , whether other info we present can be overridden by flags, I think not in the container area (not sure about the whole hs_err output).
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.
Sorry, I was wrong. I misread int i = OSContainer::active_processor_count();
for int i = os::active_processor_count();
which would then return the same value. As @dholmes-ora said, the original format was fine. Please add this in the test, though. Could be akin to test/hotspot/jtreg/containers/docker/TestMisc.testPrintContainerInfo()
. I.e. set some CPU quota and also ActiveProcessorCount and assert the message in log output.
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.
Sorry, I was wrong. I misread
int i = OSContainer::active_processor_count();
forint i = os::active_processor_count();
which would then return the same value. As @dholmes-ora said, the original format was fine. Please add this in the test, though. Could be akin totest/hotspot/jtreg/containers/docker/TestMisc.testPrintContainerInfo()
. I.e. set some CPU quota and also ActiveProcessorCount and assert the message in log output.
Hi Severin, I adjusted the output again; also adjusted the jtreg test containers/docker/TestMisc .
Best regards, Matthias
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.
Hmm, not sure why it recorded my comment as "approval".
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.
Seems fine to me.
Does make me wonder whether other info we present can be overridden by flags.
Thanks,
David
src/hotspot/os/linux/os_linux.cpp
Outdated
@@ -2174,7 +2174,12 @@ bool os::Linux::print_container_info(outputStream* st) { | |||
int i = OSContainer::active_processor_count(); | |||
st->print("active_processor_count: "); | |||
if (i > 0) { | |||
st->print_cr("%d", i); | |||
if (ActiveProcessorCount > 0) { | |||
st->print_cr("%d, but overwritten by flag ActiveProcessorCount: %d", |
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 format is fine me with me. You want to see both the container processor count and the actual count being used.
Thanks for the review. Indeed only ActiveProcessorCount > 0 results in special handling, so 0 and -1 are both leading to the same runtime behavior. |
@@ -86,7 +86,7 @@ private static void testIsContainerized() throws Exception { | |||
private static void testPrintContainerInfo() throws Exception { | |||
Common.logNewTestCase("Test print_container_info()"); | |||
|
|||
DockerRunOptions opts = Common.newOpts(imageName, "PrintContainerInfo"); | |||
DockerRunOptions opts = Common.newOpts(imageName, "PrintContainerInfo", "-XX:ActiveProcessorCount=2"); |
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.
It would be better to separate this specific test. More like this:
jerboaa@3911ef8
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.
I'm not sure I like this version of the test better. I'd rather separate concerns. The changes to Common
aren't really needed, as Common.newOpts(imageName, "PrintContainerInfo").addJavaOpts("-XX:ActiveProcessorCount=2");
can be used instead. Similarly, the changes to checkContainerInfo()
make the test harder to read. It's once called with a null
argument and checks similar things, but one additional assert. Rather than that, I'd just do the assert directly in the new test as suggested. This saves the reader having to look up call-sites to know what the test is actually asserting. This also more closely matches what's likely to happen in real scenarios (override the container detection heuristics with -XX:ActiveProcessorCount
).
@@ -71,6 +71,14 @@ public static DockerRunOptions newOpts(String imageNameAndTag, String testClass) | |||
return opts; | |||
} | |||
|
|||
public static DockerRunOptions newOpts(String imageNameAndTag, String testClass, String addJavaOpts) { |
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.
It would be good to avoid code duplication and just e.g. have the no-arg newOpts
pass null
for addJavaOpts
.
…uplication in Common
Hi David and Severin, I added a separate test to TestMisc. Additionally I adjusted Common.java to avoid code duplication. |
@@ -86,7 +86,7 @@ private static void testIsContainerized() throws Exception { | |||
private static void testPrintContainerInfo() throws Exception { | |||
Common.logNewTestCase("Test print_container_info()"); | |||
|
|||
DockerRunOptions opts = Common.newOpts(imageName, "PrintContainerInfo"); | |||
DockerRunOptions opts = Common.newOpts(imageName, "PrintContainerInfo", "-XX:ActiveProcessorCount=2"); |
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.
I'm not sure I like this version of the test better. I'd rather separate concerns. The changes to Common
aren't really needed, as Common.newOpts(imageName, "PrintContainerInfo").addJavaOpts("-XX:ActiveProcessorCount=2");
can be used instead. Similarly, the changes to checkContainerInfo()
make the test harder to read. It's once called with a null
argument and checks similar things, but one additional assert. Rather than that, I'd just do the assert directly in the new test as suggested. This saves the reader having to look up call-sites to know what the test is actually asserting. This also more closely matches what's likely to happen in real scenarios (override the container detection heuristics with -XX:ActiveProcessorCount
).
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.
LGTM
Hi Severin, indeed we can live without changing Common.java; adjusted the test. |
/integrate |
Going to push as commit bb2e10c.
Your commit was automatically rebased without conflicts. |
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.
Only a single reviewer approved the final version of these changes so it may have been prudent to seek a least one additional re-review. I had it on my to-do list. :)
The updated test looks much cleaner and simpler.
Thanks,
David
The function os::Linux::print_container_info outputs memory- and cpu-related container information (when running in a containerized environment).
However in the case of active processor count , it currently just outputs the info from OSContainer::active_processor_count without looking at ActiveProcessorCount that can be set to overwrite the OSContainer::active_processor_count() - information. This should be improved.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/7354/head:pull/7354
$ git checkout pull/7354
Update a local copy of the PR:
$ git checkout pull/7354
$ git pull https://git.openjdk.java.net/jdk pull/7354/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 7354
View PR using the GUI difftool:
$ git pr show -t 7354
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/7354.diff