RFR: 8292206: TestCgroupMetrics.java fails as getMemoryUsage() is lower than expected
Ioi Lam
iklam at openjdk.org
Tue Dec 20 00:18:47 UTC 2022
On Tue, 20 Dec 2022 00:03:25 GMT, Ioi Lam <iklam at openjdk.org> wrote:
> The `testMemoryUsage()` test scenario queries the total memory usage of all processes of the current Linux user, including other concurrently running jtreg test cases. Even if the current process allocates 256MB of ram, it's possible for other dying processes to release much more than that amount. Therefore, it's not possible to guarantee that `Metrics.getMemoryUsage()` would return a higher number.
>
> I am removing this test scenario for now as I don't see it providing any actual value.
>
> If we want to have more in-depth functional tests for the `Metrics.getMemoryXXX()` APIs, we need to do it inside a container in a more controlled setting.
Note: theoretically other test scenarios can also fail for the same reason, but we've never seen them fail in our CI pipeline
https://github.com/openjdk/jdk/blob/ba942c24e8894f4422870fb53253f5946dc4f0d1/test/lib/jdk/test/lib/containers/cgroup/MetricsTesterCgroupV1.java (see lines L250-L254)
oldVal = metrics.getKernelMemoryMaxUsage();
newVal = getLongValueFromFile(Controller.MEMORY, "memory.kmem.max_usage_in_bytes");
if (!CgroupMetricsTester.compareWithErrorMargin(oldVal, newVal)) {
fail(Controller.MEMORY, "memory.kmem.max_usage_in_bytes", oldVal, newVal);
}
`compareWithErrorMargin` checks that the difference is less than 25%, which probably will never happen between the first two lines in the code quoted above. Other usage of `compareWithErrorMargin` in the same test may suffer the same problem.
-------------
PR: https://git.openjdk.org/jdk/pull/11734
More information about the hotspot-runtime-dev
mailing list