8312525: New test runtime/os/TestTrimNative.java#trimNative is failing: did not see the expected RSS reduction

Reviewed-by: dholmes, shade
This commit is contained in:
Thomas Stuefe 2023-07-29 05:36:58 +00:00
parent d6245b6832
commit ad34be1f32
3 changed files with 43 additions and 12 deletions
src/hotspot/os/linux
test/hotspot/jtreg

@ -24,6 +24,7 @@
*/
#include "precompiled.hpp"
#include "logging/log.hpp"
#include "runtime/os.inline.hpp"
#include "trimCHeapDCmd.hpp"
#include "utilities/debug.hpp"
@ -42,6 +43,9 @@ void TrimCLibcHeapDCmd::execute(DCmdSource source, TRAPS) {
const char sign = sc.after < sc.before ? '-' : '+';
_output->print_cr("RSS+Swap: " PROPERFMT "->" PROPERFMT " (%c" PROPERFMT ")",
PROPERFMTARGS(sc.before), PROPERFMTARGS(sc.after), sign, PROPERFMTARGS(delta));
// Also log if native trim log is active
log_info(trimnative)("Manual Trim: " PROPERFMT "->" PROPERFMT " (%c" PROPERFMT ")",
PROPERFMTARGS(sc.before), PROPERFMTARGS(sc.after), sign, PROPERFMTARGS(delta));
} else {
_output->print_cr("(no details available).");
}

@ -98,8 +98,6 @@ runtime/os/TestTracePageSizes.java#compiler-options 8267460 linux-aarch64
runtime/os/TestTracePageSizes.java#G1 8267460 linux-aarch64
runtime/os/TestTracePageSizes.java#Parallel 8267460 linux-aarch64
runtime/os/TestTracePageSizes.java#Serial 8267460 linux-aarch64
runtime/os/TestTrimNative.java#trimNative 8312525 linux-all
runtime/os/TestTrimNative.java#trimNativeLowInterval 8312525 linux-all
runtime/ErrorHandling/CreateCoredumpOnCrash.java 8267433 macosx-x64
runtime/CompressedOops/CompressedClassPointers.java 8305765 generic-all
runtime/StackGuardPages/TestStackGuardPagesNative.java 8303612 linux-all

@ -34,6 +34,16 @@
* @run driver TestTrimNative trimNative
*/
/*
* @test id=trimNativeStrict
* @requires (os.family=="linux") & !vm.musl
* @modules java.base/jdk.internal.misc
* @library /test/lib
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run main/manual TestTrimNative trimNativeStrict
*/
/*
* @test id=trimNativeHighInterval
* @summary High interval trimming should not even kick in for short program runtimes
@ -56,6 +66,17 @@
* @run driver TestTrimNative trimNativeLowInterval
*/
/*
* @test id=trimNativeLowIntervalStrict
* @summary Very low (sub-second) interval, nothing should explode (stricter test, manual mode)
* @requires (os.family=="linux") & !vm.musl
* @modules java.base/jdk.internal.misc
* @library /test/lib
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run main/manual TestTrimNative trimNativeLowIntervalStrict
*/
/*
* @test id=testOffByDefault
* @summary Test that trimming is disabled by default
@ -161,9 +182,10 @@ public class TestTrimNative {
* @param output
* @param minTrimsExpected min number of periodic trim lines expected in UL log
* @param maxTrimsExpected min number of periodic trim lines expected in UL log
* @param strict: if true, expect RSS to go down; if false, just look for trims without looking at RSS.
*/
private static void parseOutputAndLookForNegativeTrim(OutputAnalyzer output, int minTrimsExpected,
int maxTrimsExpected) {
int maxTrimsExpected, boolean strict) {
output.reportDiagnosticSummary();
List<String> lines = output.asLines();
Pattern pat = Pattern.compile(".*\\[trimnative\\] Periodic Trim \\(\\d+\\): (\\d+)([BKMG])->(\\d+)([BKMG]).*");
@ -188,7 +210,8 @@ public class TestTrimNative {
throw new RuntimeException("We found fewer (periodic) trim lines in UL log than expected (expected at least " + minTrimsExpected +
", found " + numTrimsFound + ").");
}
if (maxTrimsExpected > 0) {
System.out.println("Found " + numTrimsFound + " trims. Ok.");
if (strict && maxTrimsExpected > 0) {
// This is very fuzzy. Test program malloced X bytes, then freed them again and trimmed. But the log line prints change in RSS.
// Which, of course, is influenced by a lot of other factors. But we expect to see *some* reasonable reduction in RSS
// due to trimming.
@ -203,6 +226,8 @@ public class TestTrimNative {
if (rssReductionTotal < expectedMinimalReduction) {
throw new RuntimeException("We did not see the expected RSS reduction in the UL log. Expected (with fudge)" +
" to see at least a combined reduction of " + expectedMinimalReduction + ".");
} else {
System.out.println("Found high enough RSS reduction from trims: " + rssReductionTotal);
}
}
}
@ -238,8 +263,11 @@ public class TestTrimNative {
throw new RuntimeException("Argument error");
}
boolean strictTesting = args[0].endsWith("Strict");
switch (args[0]) {
case "trimNative": {
case "trimNative":
case "trimNativeStrict": {
long trimInterval = 500; // twice per second
long ms1 = System.currentTimeMillis();
OutputAnalyzer output = runTestWithOptions(
@ -253,7 +281,7 @@ public class TestTrimNative {
long maxTrimsExpected = runtime_ms / trimInterval;
long minTrimsExpected = maxTrimsExpected / 2;
parseOutputAndLookForNegativeTrim(output, (int) minTrimsExpected, (int) maxTrimsExpected);
parseOutputAndLookForNegativeTrim(output, (int) minTrimsExpected, (int) maxTrimsExpected, strictTesting);
} break;
case "trimNativeHighInterval": {
@ -263,16 +291,17 @@ public class TestTrimNative {
);
checkExpectedLogMessages(output, true, Integer.MAX_VALUE);
// We should not see any trims since the interval would prevent them
parseOutputAndLookForNegativeTrim(output, 0, 0);
parseOutputAndLookForNegativeTrim(output, 0, 0, strictTesting);
} break;
case "trimNativeLowInterval": {
case "trimNativeLowInterval":
case "trimNativeLowIntervalStrict": {
OutputAnalyzer output = runTestWithOptions(
new String[] { "-XX:+UnlockExperimentalVMOptions", "-XX:TrimNativeHeapInterval=1" },
new String[] { TestTrimNative.Tester.class.getName(), "0" }
);
checkExpectedLogMessages(output, true, 1);
parseOutputAndLookForNegativeTrim(output, 1, 3000);
parseOutputAndLookForNegativeTrim(output, 1, 3000, strictTesting);
} break;
case "testOffOnNonCompliantPlatforms": {
@ -281,7 +310,7 @@ public class TestTrimNative {
new String[] { "-version" }
);
checkExpectedLogMessages(output, false, 0);
parseOutputAndLookForNegativeTrim(output, 0, 0);
parseOutputAndLookForNegativeTrim(output, 0, 0, strictTesting);
// The following output is expected to be printed with warning level, so it should not need -Xlog
output.shouldContain("[warning][trimnative] Native heap trim is not supported on this platform");
} break;
@ -292,13 +321,13 @@ public class TestTrimNative {
new String[] { "-version" }
);
checkExpectedLogMessages(output, false, 0);
parseOutputAndLookForNegativeTrim(output, 0, 0);
parseOutputAndLookForNegativeTrim(output, 0, 0, strictTesting);
} break;
case "testOffByDefault": {
OutputAnalyzer output = runTestWithOptions(null, new String[] { "-version" } );
checkExpectedLogMessages(output, false, 0);
parseOutputAndLookForNegativeTrim(output, 0, 0);
parseOutputAndLookForNegativeTrim(output, 0, 0, strictTesting);
} break;
default: