RFR: 8313770: jdk/internal/platform/docker/TestSystemMetrics.java fails on Ubuntu

Severin Gehwolf sgehwolf at openjdk.org
Wed Oct 22 09:14:41 UTC 2025


On Wed, 22 Oct 2025 08:49:07 GMT, Casper Norrbin <cnorrbin at openjdk.org> wrote:

> Hi everyone,
> 
> The test `TestSystemMetrics.java` sometimes fails on cgroupv2 when comparing read/write I/O metrics (`rios`/`wios`) because the expected value doesn't match the one read from the `io.stat` file. The current approach in this test is somewhat flawed, it reads from the same `io.stat` file cgroup file twice, once directly and once through `jdk.internal.platform.Metrics`, and assumes the values should be identical. In practice, this assumption does not hold. Unrelated I/O running in the same cgroup may increment the counter between reads, leading to discrepancies. 
> 
> The current comparisons have a 25% margin from the original value to account for incidental noise, but this doesn't work well on the I/O operation counters, which can have very small values (sometimes as low as 0), which makes the percentage-based margin useless. As a result, this test is at risk of failing whenever activity happens between the 2 file readings.
> 
> For greater reliability, I suggest we should instead check that the value is increasing rather than expecting equality. This is already done for other metrics, such as CPU and memory usage, and more accurately reflects the expected behaviour of the counters. Switching to this check removes the reliance on error margins and results in a more stable and meaningful test.
> 
> Testing:
> - Repeated runs of `TestSystemMetrics.java`  without any observed failures.
> - Oracle tiers 1-5

Looks good.

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

Marked as reviewed by sgehwolf (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/27934#pullrequestreview-3364548250


More information about the hotspot-runtime-dev mailing list