RFR: 8335625: Update Javadoc for GetCpuLoad [v3]
Alan Bateman
alanb at openjdk.org
Fri Aug 23 12:04:04 UTC 2024
On Fri, 23 Aug 2024 08:49:38 GMT, Joakim Nordström <jnordstrom at openjdk.org> wrote:
>> Can I get a review of this documentation update to clarify the usage of GetCpuLoad (and inherently deprecated GetSystemCpuLoad) and GetProcessCpuLoad.
>>
>> Calling either of these methods in quick succession can lead to unrepresentative results due to too few data points.
>>
>> This behavior is easy to reproduce on at least Linux (Windows implementation enforces a 500 ticks duration); when calling GetCpuLoad repeatedly CPU load values of either 0, 0.5, or 1 will be returned.
>>
>> double cpuLoad1 = getCpuLoad();
>> double cpuLoad2 = getCpuLoad(); // not enough ticks has passed to give representative values
>>
>> Worth noting is that this holds true even if getSystemCpuLoad() is called.
>>
>> double cpuLoad1 = getCpuLoad();
>> double cpuLoad2 = getSystemCpuLoad(); // not enough ticks has passed to give representative values, since getSystemCpuLoad effectively calls getCpuLoad.
>
> Joakim Nordström has updated the pull request incrementally with one additional commit since the last revision:
>
> Added implNote and made some re-arrangements
src/jdk.management/share/classes/com/sun/management/OperatingSystemMXBean.java line 154:
> 152: * affecting the observation period and the result.
> 153: *
> 154: * @implNote There is only one observation period for the entire JVM
This version looks good, I'm just wondering about the implNote, is the statement true for all implementations (Linux, macOS, Windows, ...)?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20546#discussion_r1728859410
More information about the serviceability-dev
mailing list