Skip to content

Commit 9ad6dc8

Browse files
committed
8306774: Make runtime/Monitor/GuaranteedAsyncDeflationIntervalTest.java more reliable
Reviewed-by: stuefe, dcubed
1 parent c5910fa commit 9ad6dc8

File tree

2 files changed

+30
-15
lines changed

2 files changed

+30
-15
lines changed

test/hotspot/jtreg/ProblemList.txt

-4
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ runtime/CompressedOops/CompressedClassPointers.java 8305765 generic-all
101101
runtime/StackGuardPages/TestStackGuardPagesNative.java 8303612 linux-all
102102
runtime/Thread/TestAlwaysPreTouchStacks.java 8305416 generic-all
103103
runtime/ErrorHandling/TestDwarf.java 8305489 linux-all
104-
runtime/Monitor/GuaranteedAsyncDeflationIntervalTest.java#allDisabled 8306774 generic-all
105-
runtime/Monitor/GuaranteedAsyncDeflationIntervalTest.java#guaranteedNoADI 8306774 generic-all
106-
runtime/Monitor/GuaranteedAsyncDeflationIntervalTest.java#allEnabled 8306774 generic-all
107-
runtime/Monitor/GuaranteedAsyncDeflationIntervalTest.java#guaranteedNoMUDT 8306774 generic-all
108104

109105
applications/jcstress/copy.java 8229852 linux-all
110106

test/hotspot/jtreg/runtime/Monitor/GuaranteedAsyncDeflationIntervalTest.java

+30-11
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,40 @@ public class GuaranteedAsyncDeflationIntervalTest {
5858

5959
public static class Test {
6060
// Inflate a lot of monitors, so that threshold heuristics definitely fires
61-
public static final int MONITORS = 10_000;
61+
private static final int MONITORS = 10_000;
6262

63-
public static Object[] monitors;
63+
// Use a handful of threads to inflate the monitors, to eat the cost of
64+
// wait(1) calls. This can be larger than available parallelism, since threads
65+
// would be time-waiting.
66+
private static final int THREADS = 16;
67+
68+
private static Thread[] threads;
69+
private static Object[] monitors;
6470

6571
public static void main(String... args) throws Exception {
6672
monitors = new Object[MONITORS];
67-
for (int i = 0; i < MONITORS; i++) {
68-
Object o = new Object();
69-
synchronized (o) {
70-
try {
71-
o.wait(1); // Inflate!
72-
} catch (InterruptedException ie) {
73+
threads = new Thread[THREADS];
74+
75+
for (int t = 0; t < THREADS; t++) {
76+
int monStart = t * MONITORS / THREADS;
77+
int monEnd = (t + 1) * MONITORS / THREADS;
78+
threads[t] = new Thread(() -> {
79+
for (int m = monStart; m < monEnd; m++) {
80+
Object o = new Object();
81+
synchronized (o) {
82+
try {
83+
o.wait(1);
84+
} catch (InterruptedException e) {
85+
}
86+
}
87+
monitors[m] = o;
7388
}
74-
}
75-
monitors[i] = o;
89+
});
90+
threads[t].start();
91+
}
92+
93+
for (Thread t : threads) {
94+
t.join();
7695
}
7796

7897
try {
@@ -170,7 +189,7 @@ public static void testAllEnabled() throws Exception {
170189
"-Xmx100M",
171190
"-XX:+UnlockDiagnosticVMOptions",
172191
"-XX:GuaranteedAsyncDeflationInterval=5000",
173-
"-XX:MonitorUsedDeflationThreshold=10",
192+
"-XX:MonitorUsedDeflationThreshold=1",
174193
"-Xlog:monitorinflation=info",
175194
"GuaranteedAsyncDeflationIntervalTest$Test");
176195

0 commit comments

Comments
 (0)