> Please review this PR that makes "failcount" case of 
> `TestDockerMemoryMetrics.java` more robust.
> The "failcount" case is failing in some environments (OL9+ in my case).
> 
> With this change I am trying to address several issues:
> * the test was not setting swap-space, and assumed OS will map mirror 
> `--memory` in size. 128MiB for the test was not always enough for a 
> successful run.
>    * updated the test with additional `--memory-swap` flat to control the 
> swap headroom in container so that failcount gets more chances to be 
> incremented while main memory is full. It may also be that some OSes are more 
> eager the others to update counters in cgroup-fs. This tweak helps.
> *  the `new byte[1 MiB]` allocations alone reserves heap space for the 
> application space but may leave the memory uncommitted. It can be that 512 
> MiB Java heap fills up and throws OutOfMemoryError before RSS crosses the 
> 128MiB limit.
>   * fix by dirtying the chunks after we allocate them.
> * removed `catch`'ing `java.lang.OutOfMemoryError` errors to avoid secondary 
> `OutOfMemoryError`.
> * The test inherits JVM flags set externally and so `-Xmx` is often passed to 
> the JVM running in a container.
>   *  Make `-Xmx` flag set from within the test to *win* over the one set 
> externally (e.g. by our make scripts for task definition).
> 
> * the additional logs help seeing the dynamics of the test, Example OL9:
> 
> Initial memory fail count: 0
> Allocated:   0M, Memory usage:  42M, Memory and swap:  42M
> .......Allocated:   8M, Memory usage:  72M, Memory and swap:  72M
> .......Allocated:  16M, Memory usage:  88M, Memory and swap:  88M
> .......Allocated:  24M, Memory usage: 106M, Memory and swap: 106M
> .......Allocated:  32M, Memory usage: 123M, Memory and swap: 123M
> .......Allocated:  40M, Memory usage: 127M, Memory and swap: 142M
> .......Allocated:  48M, Memory usage: 127M, Memory and swap: 163M
> .......Allocated:  56M, Memory usage:  97M, Memory and swap: 185M
> .......Allocated:  64M, Memory usage: 113M, Memory and swap: 200M
> .......Allocated:  72M, Memory usage: 127M, Memory and swap: 215M
> .......Allocated:  80M, Memory usage: 127M, Memory and swap: 251M
> .......Allocated:  88M, Memory usage: 127M, Memory and swap: 249M
> .......Allocated:  96M, Memory usage: 127M, Memory and swap: 266M
> .......Allocated: 104M, Memory usage: 125M, Memory and swap: 287M
> .
> DEBUG: Bytes allocation length 1: 1048576
> Final memory fail count: 1
> TEST PASSED!!!
> ``` 
> 
> Tested `TestDockerMemoryMetrics.java` on
> * Ubuntu 24.04 x {Podman, Docker} 
> * OL9,10 + Pod...

Ivan Bereziuk has updated the pull request incrementally with one additional 
commit since the last revision:

  space alias fix. comment tweak

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/32300/files
  - new: https://git.openjdk.org/jdk/pull/32300/files/5aee9f4a..b54790fc

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=32300&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=32300&range=00-01

  Stats: 2 lines in 2 files changed: 0 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/32300.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/32300/head:pull/32300

PR: https://git.openjdk.org/jdk/pull/32300

Reply via email to