-
Notifications
You must be signed in to change notification settings - Fork 720
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
getProcessCpuLoad() always return -1 in first call on jdk11 #13389
Comments
fyi @keithc-ca |
The behavior is consistent with the specification at [1]:
|
@keithc-ca Thanks for your reply, yeah I understand that the negative return value is allowed, and also we know the first call probably could not retrieve the correct recent cpu usage, so the behavior is expected. |
@Sidong-Wei It's not clear to me whether you're suggesting changes to your application (ignore the first -1 returned), or suggesting that OpenJ9 return 0 instead of -1 from the first call. The latter does seem reasonable to me, but we'll have to consider existing use cases (and tests) that might be affected by such a change. |
@keithc-ca Yeah I also prefer the latter option a bit more. Changes to the application would definitely work and it could be a workaround for the issue, but I think if it could be resolved at the source then it would be easier for downstream applications to just monitor negative returns normally. |
Controlling the behavior via a command line option is one way to avoid compatibility problems. |
@pshipton, I assume you mean the option would restore the old (current) behavior, otherwise the default would still be inconsistent with openjdk? Got a proposal for the option name? The behavior of |
For compatibility I suggest the default behavior remain the same, although we can change it on a release boundary (Java 18 or maybe Java 17 if we do it soon) and document the change. |
I'm wondering if I could get an update on where this issue stands? Is there a plan to implement it in a particular release? |
@tajila question about scheduling this. |
Just wanted to check in on the status of this issue again. |
It's in the backlog, so no. |
@thallium Please take a look at this |
@TobiAjila Does that mean I need to implement the |
Yes, and you'll need to change the behaviour of |
@TobiAjila As suggested in #13389 (comment), do we also want to change behaviour of |
Yes, both should mirror each other.
I think its safe to assume that the only the JVM will be calling this. Its possible that someone writes a native and calls before using the MXBean api, but in that case I think we would behave similar to the RI. We can verifiy that to be sure. In any case, the main change here is that, instead of returning -1, we return zero. We are not tracking how many times the call has been made. |
I'd assume you mean returning 0 from |
The main changes will be made to |
Currently, getProcessCpuLoad() and getSystemCpuLoad() return -1 if only one data point has been recorded. A compatibility flag -XX:[+/-]CpuLoadCompatibility is added to match the behaviour of the RI, which is to return 0. Fixes: eclipse-openj9#13389 Related: eclipse-omr/omr#7189 Signed-off-by: Gengchen Tuo <gengchen.tuo@ibm.com>
Currently, getProcessCpuLoad() and getSystemCpuLoad() return -1 if only one data point has been recorded. A compatibility flag -XX:[+/-]CpuLoadCompatibility is added to match the behaviour of the RI, which is to return 0. Fixes: eclipse-openj9#13389 Related: eclipse-omr/omr#7189 Signed-off-by: Gengchen Tuo <gengchen.tuo@ibm.com>
Currently, getProcessCpuLoad() and getSystemCpuLoad() return -1 if only one data point has been recorded. A compatibility flag -XX:[+/-]CpuLoadCompatibility is added to match the behaviour of the RI, which is to return 0. Fixes: eclipse-openj9#13389 Related: eclipse-omr/omr#7189 Signed-off-by: Gengchen Tuo <gengchen.tuo@ibm.com>
Java -version output
Summary of problem
The
getProcessCpuLoad()
method of classcom.sun.management.OperatingSystemMXBean
always return -1 (invaild ret value) in the first call, while in the following calls it will get the correct cpu load value.I tried to call the same function using OpenJDK11 and AdoptOpenJDK11 with Hotspot, and it will return 0 with these JDKs which is within the valid ret value range. So I expect Openj9 should also have the same behavior for the first call. Here is a simple test code that could reproduce the issue:
Diagnostic files
The output I got with different JDK variants is:
I also tried the previous stable release (11.0.11+9) and the current
openj9
branch and the output is similar.The text was updated successfully, but these errors were encountered: