8306774: Make runtime/Monitor/GuaranteedAsyncDeflationIntervalTest.java more reliable

Reviewed-by: stuefe, dcubed
This commit is contained in:
Aleksey Shipilev 2023-04-26 11:11:54 +00:00
parent c5910fa065
commit 9ad6dc881d
2 changed files with 30 additions and 15 deletions

@ -101,10 +101,6 @@ runtime/CompressedOops/CompressedClassPointers.java 8305765 generic-all
runtime/StackGuardPages/TestStackGuardPagesNative.java 8303612 linux-all
runtime/Thread/TestAlwaysPreTouchStacks.java 8305416 generic-all
runtime/ErrorHandling/TestDwarf.java 8305489 linux-all
runtime/Monitor/GuaranteedAsyncDeflationIntervalTest.java#allDisabled 8306774 generic-all
runtime/Monitor/GuaranteedAsyncDeflationIntervalTest.java#guaranteedNoADI 8306774 generic-all
runtime/Monitor/GuaranteedAsyncDeflationIntervalTest.java#allEnabled 8306774 generic-all
runtime/Monitor/GuaranteedAsyncDeflationIntervalTest.java#guaranteedNoMUDT 8306774 generic-all
applications/jcstress/copy.java 8229852 linux-all

@ -58,21 +58,40 @@ public class GuaranteedAsyncDeflationIntervalTest {
public static class Test {
// Inflate a lot of monitors, so that threshold heuristics definitely fires
public static final int MONITORS = 10_000;
private static final int MONITORS = 10_000;
public static Object[] monitors;
// Use a handful of threads to inflate the monitors, to eat the cost of
// wait(1) calls. This can be larger than available parallelism, since threads
// would be time-waiting.
private static final int THREADS = 16;
private static Thread[] threads;
private static Object[] monitors;
public static void main(String... args) throws Exception {
monitors = new Object[MONITORS];
for (int i = 0; i < MONITORS; i++) {
Object o = new Object();
synchronized (o) {
try {
o.wait(1); // Inflate!
} catch (InterruptedException ie) {
threads = new Thread[THREADS];
for (int t = 0; t < THREADS; t++) {
int monStart = t * MONITORS / THREADS;
int monEnd = (t + 1) * MONITORS / THREADS;
threads[t] = new Thread(() -> {
for (int m = monStart; m < monEnd; m++) {
Object o = new Object();
synchronized (o) {
try {
o.wait(1);
} catch (InterruptedException e) {
}
}
monitors[m] = o;
}
}
monitors[i] = o;
});
threads[t].start();
}
for (Thread t : threads) {
t.join();
}
try {
@ -170,7 +189,7 @@ public class GuaranteedAsyncDeflationIntervalTest {
"-Xmx100M",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:GuaranteedAsyncDeflationInterval=5000",
"-XX:MonitorUsedDeflationThreshold=10",
"-XX:MonitorUsedDeflationThreshold=1",
"-Xlog:monitorinflation=info",
"GuaranteedAsyncDeflationIntervalTest$Test");