OperatingSystemImpl should factor cpu shares when calculating system load

Argha C mail.arghac at gmail.com
Mon May 3 17:14:07 UTC 2021


Hello,
I wanted to report an issue we're seeing with the load calculation, when
running with cpu shares > 1, in a container environment. Specifically, the
implementation of  *OperatingSystemImpl#getCpuLoad.*

*Problem*

When running with allocation of multiple cpu shares, ie. > 1 unit, the load
numbers do not comply with the expected range of 0-1. In the example
screenshot, it goes beyond 4.
This miscalculation throws off load based system heuristics, when running
in a container based environment.

*Proposed solution*

In a container aware environment, for load average calculation, the number
of cpu cycles, ie. *getCpuPeriod *must be multiplied by the number of
requested cpu shares by the process, ie. *getCpuShares.*
This would ensure that the load calculation uses the correct denominator
for elapsed time slice periods.

In the screenshot below, this would mean using *getCpuShares *as a
multiplier for *periodLength.*

Please consider validating this behavior. I'd be happy to submit a PR but
I'm not an openjdk author/contributor.
Thanks for your consideration.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/serviceability-dev/attachments/20210503/fa5f158b/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2021-05-03 at 10.02.27 AM.png
Type: image/png
Size: 479711 bytes
Desc: not available
URL: <https://mail.openjdk.java.net/pipermail/serviceability-dev/attachments/20210503/fa5f158b/ScreenShot2021-05-03at10.02.27AM-0001.png>


More information about the serviceability-dev mailing list