8344577: Virtual thread tests are timing out on some macOS systems
Reviewed-by: jpai
This commit is contained in:
parent
4110d3925c
commit
a032de2904
@ -42,6 +42,7 @@
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import jdk.test.lib.Platform;
|
||||||
import jdk.test.lib.thread.VThreadRunner; // ensureParallelism requires jdk.management
|
import jdk.test.lib.thread.VThreadRunner; // ensureParallelism requires jdk.management
|
||||||
|
|
||||||
public class GetStackTraceALotWhenBlocking {
|
public class GetStackTraceALotWhenBlocking {
|
||||||
@ -50,7 +51,14 @@ public class GetStackTraceALotWhenBlocking {
|
|||||||
// need at least two carriers
|
// need at least two carriers
|
||||||
VThreadRunner.ensureParallelism(2);
|
VThreadRunner.ensureParallelism(2);
|
||||||
|
|
||||||
int iterations = args.length > 0 ? Integer.parseInt(args[0]) : 100_000;
|
int iterations;
|
||||||
|
int value = Integer.parseInt(args[0]);
|
||||||
|
if (Platform.isOSX() && Platform.isX64()) {
|
||||||
|
// reduced iterations on macosx-x64
|
||||||
|
iterations = Math.max(value / 4, 1);
|
||||||
|
} else {
|
||||||
|
iterations = value;
|
||||||
|
}
|
||||||
|
|
||||||
var done = new AtomicBoolean();
|
var done = new AtomicBoolean();
|
||||||
var lock = new Object();
|
var lock = new Object();
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.locks.LockSupport;
|
import java.util.concurrent.locks.LockSupport;
|
||||||
|
import jdk.test.lib.Platform;
|
||||||
import jdk.test.lib.thread.VThreadRunner; // ensureParallelism requires jdk.management
|
import jdk.test.lib.thread.VThreadRunner; // ensureParallelism requires jdk.management
|
||||||
import jdk.test.lib.thread.VThreadPinner;
|
import jdk.test.lib.thread.VThreadPinner;
|
||||||
|
|
||||||
@ -53,7 +54,15 @@ public class GetStackTraceALotWhenPinned {
|
|||||||
VThreadRunner.ensureParallelism(2);
|
VThreadRunner.ensureParallelism(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
int iterations = Integer.parseInt(args[0]);
|
int iterations;
|
||||||
|
int value = Integer.parseInt(args[0]);
|
||||||
|
if (Platform.isOSX() && Platform.isX64()) {
|
||||||
|
// reduced iterations on macosx-x64
|
||||||
|
iterations = Math.max(value / 4, 1);
|
||||||
|
} else {
|
||||||
|
iterations = value;
|
||||||
|
}
|
||||||
|
|
||||||
var barrier = new Barrier(2);
|
var barrier = new Barrier(2);
|
||||||
|
|
||||||
// Start a virtual thread that loops doing Thread.yield and parking while pinned.
|
// Start a virtual thread that loops doing Thread.yield and parking while pinned.
|
||||||
|
@ -25,13 +25,13 @@
|
|||||||
* @test
|
* @test
|
||||||
* @summary Stress test Thread.getStackTrace on a virtual thread in timed-Object.wait
|
* @summary Stress test Thread.getStackTrace on a virtual thread in timed-Object.wait
|
||||||
* @requires vm.debug != true
|
* @requires vm.debug != true
|
||||||
* @run main/othervm GetStackTraceALotWithTimedWait 100000
|
* @run main GetStackTraceALotWithTimedWait 100000
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @requires vm.debug == true
|
* @requires vm.debug == true
|
||||||
* @run main/othervm GetStackTraceALotWithTimedWait 50000
|
* @run main GetStackTraceALotWithTimedWait 50000
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
* @summary Test virtual threads entering a lot of monitors with contention
|
* @summary Test virtual threads entering a lot of monitors with contention
|
||||||
* @requires vm.opt.LockingMode != 1
|
* @requires vm.opt.LockingMode != 1
|
||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @run main/othervm LotsOfContendedMonitorEnter
|
* @run main LotsOfContendedMonitorEnter
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
* @test id=default
|
* @test id=default
|
||||||
* @summary Test virtual thread entering (and reentering) a lot of monitors with no contention
|
* @summary Test virtual thread entering (and reentering) a lot of monitors with no contention
|
||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @run main/othervm LotsOfUncontendedMonitorEnter
|
* @run main LotsOfUncontendedMonitorEnter
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -25,29 +25,35 @@
|
|||||||
* @test
|
* @test
|
||||||
* @summary Stress test parking and unparking
|
* @summary Stress test parking and unparking
|
||||||
* @requires vm.debug != true
|
* @requires vm.debug != true
|
||||||
* @run main/othervm ParkALot 500000
|
* @library /test/lib
|
||||||
|
* @run main/othervm/timeout=300 ParkALot 300000
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @requires vm.debug == true
|
* @requires vm.debug == true
|
||||||
* @run main/othervm ParkALot 100000
|
* @library /test/lib
|
||||||
|
* @run main/othervm/timeout=300 ParkALot 100000
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.locks.LockSupport;
|
import java.util.concurrent.locks.LockSupport;
|
||||||
|
import jdk.test.lib.Platform;
|
||||||
|
|
||||||
public class ParkALot {
|
public class ParkALot {
|
||||||
private static final int ITERATIONS = 1_000_000;
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) throws Exception {
|
||||||
int iterations;
|
int iterations;
|
||||||
if (args.length > 0) {
|
int value = Integer.parseInt(args[0]);
|
||||||
iterations = Integer.parseInt(args[0]);
|
if (Platform.isOSX() && Platform.isX64()) {
|
||||||
|
// reduced iterations on macosx-x64
|
||||||
|
iterations = Math.max(value / 4, 1);
|
||||||
} else {
|
} else {
|
||||||
iterations = ITERATIONS;
|
iterations = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
int maxThreads = Math.clamp(Runtime.getRuntime().availableProcessors() / 2, 1, 4);
|
int maxThreads = Math.clamp(Runtime.getRuntime().availableProcessors() / 2, 1, 4);
|
||||||
@ -55,8 +61,18 @@ public class ParkALot {
|
|||||||
System.out.format("%s %d thread(s) ...%n", Instant.now(), nthreads);
|
System.out.format("%s %d thread(s) ...%n", Instant.now(), nthreads);
|
||||||
ThreadFactory factory = Thread.ofPlatform().factory();
|
ThreadFactory factory = Thread.ofPlatform().factory();
|
||||||
try (var executor = Executors.newThreadPerTaskExecutor(factory)) {
|
try (var executor = Executors.newThreadPerTaskExecutor(factory)) {
|
||||||
|
var totalIterations = new AtomicInteger();
|
||||||
for (int i = 0; i < nthreads; i++) {
|
for (int i = 0; i < nthreads; i++) {
|
||||||
executor.submit(() -> parkALot(iterations));
|
executor.submit(() -> parkALot(iterations, totalIterations::incrementAndGet));
|
||||||
|
}
|
||||||
|
|
||||||
|
// shutdown, await for all threads to finish with progress output
|
||||||
|
executor.shutdown();
|
||||||
|
boolean terminated = false;
|
||||||
|
while (!terminated) {
|
||||||
|
terminated = executor.awaitTermination(1, TimeUnit.SECONDS);
|
||||||
|
System.out.format("%s => %d of %d%n",
|
||||||
|
Instant.now(), totalIterations.get(), iterations * nthreads);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.format("%s %d thread(s) done%n", Instant.now(), nthreads);
|
System.out.format("%s %d thread(s) done%n", Instant.now(), nthreads);
|
||||||
@ -66,8 +82,10 @@ public class ParkALot {
|
|||||||
/**
|
/**
|
||||||
* Creates a virtual thread that alternates between untimed and timed parking.
|
* Creates a virtual thread that alternates between untimed and timed parking.
|
||||||
* A platform thread spins unparking the virtual thread.
|
* A platform thread spins unparking the virtual thread.
|
||||||
|
* @param iterations number of iterations
|
||||||
|
* @param afterIteration the task to run after each iteration
|
||||||
*/
|
*/
|
||||||
private static void parkALot(int iterations) {
|
private static void parkALot(int iterations, Runnable afterIteration) {
|
||||||
Thread vthread = Thread.ofVirtual().start(() -> {
|
Thread vthread = Thread.ofVirtual().start(() -> {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
boolean timed = false;
|
boolean timed = false;
|
||||||
@ -80,6 +98,7 @@ public class ParkALot {
|
|||||||
timed = true;
|
timed = true;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
afterIteration.run();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
* @test
|
* @test
|
||||||
* @summary Stress test Thread.sleep
|
* @summary Stress test Thread.sleep
|
||||||
* @requires vm.debug != true & vm.continuations
|
* @requires vm.debug != true & vm.continuations
|
||||||
* @run main/othervm SleepALot 500000
|
* @run main SleepALot 500000
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -24,28 +24,28 @@
|
|||||||
/*
|
/*
|
||||||
* @test id=timeout
|
* @test id=timeout
|
||||||
* @summary Stress test timed-Object.wait
|
* @summary Stress test timed-Object.wait
|
||||||
* @run main/othervm TimedWaitALot 200
|
* @run main TimedWaitALot 200
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test id=timeout-notify
|
* @test id=timeout-notify
|
||||||
* @summary Test timed-Object.wait where the waiting thread is awakened with Object.notify
|
* @summary Test timed-Object.wait where the waiting thread is awakened with Object.notify
|
||||||
* at around the same time that the timeout expires.
|
* at around the same time that the timeout expires.
|
||||||
* @run main/othervm TimedWaitALot 200 true false
|
* @run main TimedWaitALot 150 true false
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test id=timeout-interrupt
|
* @test id=timeout-interrupt
|
||||||
* @summary Test timed-Object.wait where the waiting thread is awakened with Thread.interrupt
|
* @summary Test timed-Object.wait where the waiting thread is awakened with Thread.interrupt
|
||||||
* at around the same time that the timeout expires.
|
* at around the same time that the timeout expires.
|
||||||
* @run main/othervm TimedWaitALot 200 false true
|
* @run main TimedWaitALot 150 false true
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test id=timeout-notify-interrupt
|
* @test id=timeout-notify-interrupt
|
||||||
* @summary Test timed-Object.wait where the waiting thread is awakened with Object.notify
|
* @summary Test timed-Object.wait where the waiting thread is awakened with Object.notify
|
||||||
* and Thread.interrupt at around the same time that the timeout expires.
|
* and Thread.interrupt at around the same time that the timeout expires.
|
||||||
* @run main/othervm TimedWaitALot 100 true true
|
* @run main TimedWaitALot 100 true true
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
Loading…
Reference in New Issue
Block a user