dragonwell-project / dragonwell21

GNU General Public License v2.0
61 stars 18 forks source link

[upstream][TESTBUG]testMemoryFailCount in jdk/internal/platform/docker/TestDockerMemoryMetrics.java always fail because OOM killed #9

Closed sendaoYan closed 3 months ago

sendaoYan commented 8 months ago

test command(make sure docker service work correctly before test):

jtreg -va -nr -w tmp test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java
cd tmp/scratch
docker build --no-cache --tag jdk-internal:test-jdk-internal-platform-docker-TestDockerMemoryMetrics-metrics-memory jdk-internal-test-jdk-internal-platform-docker-TestDockerMemoryMetrics-metrics-memory
cd -
javac @tmp/jdk/internal/platform/docker/TestDockerMemoryMetrics.d/compile.0.jta && docker run --tty=true --rm --volume $PWD/tmp/classes/jdk/internal/platform/docker/TestDockerMemoryMetrics.d:/test-classes/ --memory=64m jdk-internal:test-jdk-internal-platform-docker-TestDockerMemoryMetrics-metrics-memory bash -c "free -h ;  /jdk/bin/java -Xmx64m -cp /test-classes/ --add-exports java.base/jdk.internal.platform=ALL-UNNAMED MetricsMemoryTester failcount" ; echo exit code: $?

actual result:

STDERR:
 stdout: [[failcount]
];
 stderr: []
 exitValue = 137

java.lang.RuntimeException: Expected to get exit value of [0], exit value is: [137]
        at jdk.test.lib.process.OutputAnalyzer.shouldHaveExitValue(OutputAnalyzer.java:521)
        at TestDockerMemoryMetrics.testMemoryFailCount(TestDockerMemoryMetrics.java:142)
        at TestDockerMemoryMetrics.main(TestDockerMemoryMetrics.java:78)

               total        used        free      shared  buff/cache   available
Mem:           185Gi       2.9Gi        49Gi       2.0Mi       133Gi       181Gi
Swap:             0B          0B          0B
[failcount]
exit code: 137

jdk version and environment Infomation:

# uname -a ; cat /etc/os-release ; free -h ; lscpu | head -n 25 ; java -version ; java -Xinternalversion
Linux aqa-tests 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
PRETTY_NAME="Ubuntu 22.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
               total        used        free      shared  buff/cache   available
Mem:           185Gi       2.9Gi        49Gi       2.0Mi       133Gi       181Gi
Swap:             0B          0B          0B
Architecture:                       x86_64
CPU op-mode(s):                     32-bit, 64-bit
Address sizes:                      46 bits physical, 48 bits virtual
Byte Order:                         Little Endian
CPU(s):                             48
On-line CPU(s) list:                0-47
Vendor ID:                          GenuineIntel
Model name:                         Intel(R) Xeon(R) Platinum 8369HB CPU @ 3.30GHz
CPU family:                         6
Model:                              85
Thread(s) per core:                 2
Core(s) per socket:                 24
Socket(s):                          1
Stepping:                           11
CPU max MHz:                        4200.0000
CPU min MHz:                        1200.0000
BogoMIPS:                           6599.99
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves avx512_bf16 ida arat avx512_vnni
Hypervisor vendor:                  KVM
Virtualization type:                full
L1d cache:                          768 KiB (24 instances)
L1i cache:                          768 KiB (24 instances)
L2 cache:                           24 MiB (24 instances)
L3 cache:                           33 MiB (1 instance)
NUMA node(s):                       1
openjdk version "23" 2024-09-17
OpenJDK Runtime Environment (build 23)
OpenJDK 64-Bit Server VM (build 23, mixed mode, sharing)
OpenJDK 64-Bit Server VM (23) for linux-amd64 JRE (23), built on 2024-01-10T08:06:36Z by "yansendao" with gcc 11.4.0
sendaoYan commented 8 months ago

fix patch:

diff --git a/test/jdk/jdk/internal/platform/docker/MetricsMemoryTester.java b/test/jdk/jdk/internal/platform/docker/MetricsMemoryTester.java
index 08773b3e8b5..fdf6707b23f 100644
--- a/test/jdk/jdk/internal/platform/docker/MetricsMemoryTester.java
+++ b/test/jdk/jdk/internal/platform/docker/MetricsMemoryTester.java
@@ -73,11 +73,11 @@ private static void testMemoryFailCount() {
             long count = Metrics.systemMetrics().getMemoryFailCount();

             // Allocate 512M of data
-            byte[][] bytes = new byte[64][];
+            byte[][] bytes = new byte[64 * 8 * 1024][];
             boolean atLeastOneAllocationWorked = false;
-            for (int i = 0; i < 64; i++) {
+            for (int i = 0; i < 64 * 8 * 1024; i++) {
                 try {
-                    bytes[i] = new byte[8 * 1024 * 1024];
+                    bytes[i] = new byte[1024];
                     atLeastOneAllocationWorked = true;
                     // Break out as soon as we see an increase in failcount
                     // to avoid getting killed by the OOM killer.
sendaoYan commented 7 months ago

https://github.com/openjdk/jdk/pull/17386

sendaoYan commented 7 months ago

https://github.com/openjdk/jdk/pull/17514

sendaoYan commented 3 months ago

https://code.alibaba-inc.com/os-quality/tone-matrix-compiler/codereview/17005850