On Thu, 27 May 2021 00:47:23 GMT, Yasumasa Suenaga <ysuen...@openjdk.org> wrote:

> I haven't followed yet all of discussions in this review, but I concern this 
> PR changes the meaning of `getCpuLoad()`.

Does it? Here is the javadoc:
https://docs.oracle.com/en/java/javase/16/docs/api/jdk.management/com/sun/management/OperatingSystemMXBean.html#getCpuLoad()

It says:

Returns the "recent cpu usage" for the operating environment. This value is a 
double in the [0.0,1.0] interval.


If I run outside a container, getCpuLoad0() is being used which uses a similar 
calculation. So in my book this fixes the bug (earlier reporting is just plain 
wrong, see bug for details) and just brings it in line with the non-container 
values.

Also note that the cpu quota-based limits implementation as been changed to 
also report recent load values. But I'm not sure it's worth discussing this 
further as the previous implementation (supposedly reporting an average) was 
wrong.

> `getCpuLoad()` has been based on total time since the start of the container, 
> but after this PR, it is based on the ticks in earlier call. Is it ok?

IMHO, yes as the previous implementation was incorrect. I suspect nobody 
noticed until now.

> IMHO it can be accepted because it is the same with load average on Linux, 
> but I concern we may need CSR because this PR changes behavior.

I disagree. This change makes `getCpuLoad()` behave similar in all cases: 
non-container case[1], cpu affinity-based[2], cpu-quota-based[3] and cpu-shares 
based[3] cpu-limits. That wasn't previously the case.

[1] 
https://bugs.openjdk.java.net/browse/JDK-8265836?focusedCommentId=14423632&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-14423632
[2] 
https://bugs.openjdk.java.net/browse/JDK-8265836?focusedCommentId=14423633&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-14423633
[3] 
https://bugs.openjdk.java.net/browse/JDK-8265836?focusedCommentId=14423371&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-14423371

-------------

PR: https://git.openjdk.java.net/jdk/pull/3656

Reply via email to