Skip to content

Commit

Permalink
8293940: Some tests for virtual threads take too long
Browse files Browse the repository at this point in the history
Reviewed-by: dfuchs
  • Loading branch information
Alan Bateman committed Sep 30, 2022
1 parent 1d26c4b commit b8f9a91
Show file tree
Hide file tree
Showing 11 changed files with 363 additions and 297 deletions.
346 changes: 180 additions & 166 deletions test/jdk/java/lang/Thread/virtual/ThreadAPI.java

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions test/jdk/java/lang/Thread/virtual/stress/PinALot.java
Expand Up @@ -21,19 +21,19 @@
* questions.
*/

/**
/*
* @test
* @requires vm.debug != true
* @compile --enable-preview -source ${jdk.version} PinALot.java
* @run main/othervm --enable-preview PinALot
* @summary Stress test timed park when pinned
* @requires vm.debug != true
* @enablePreview
* @run main PinALot 500000
*/

/**
/*
* @test
* @requires vm.debug == true
* @compile --enable-preview -source ${jdk.version} PinALot.java
* @run main/othervm/timeout=300 --enable-preview PinALot 200000
* @enablePreview
* @run main/othervm/timeout=300 PinALot 200000
*/

import java.time.Duration;
Expand Down
19 changes: 13 additions & 6 deletions test/jdk/java/lang/Thread/virtual/stress/PingPong.java
Expand Up @@ -21,13 +21,20 @@
* questions.
*/

/**
* @test
* @summary Stress test virtual threads with SynchronousQueue and LinkedTransferQueue
/*
* @test id=sq
* @summary Stress test virtual threads with a SynchronousQueue
* @requires vm.debug != true
* @enablePreview
* @run main PingPong SQ 500000
*/

/*
* @test id=ltq
* @summary Stress test virtual threads with a LinkedTransferQueue
* @requires vm.debug != true
* @compile --enable-preview -source ${jdk.version} PingPong.java
* @run main/othervm --enable-preview PingPong SQ 1000000
* @run main/othervm --enable-preview PingPong LTQ 1000000
* @enablePreview
* @run main PingPong LTQ 500000
*/

import java.time.Duration;
Expand Down
17 changes: 8 additions & 9 deletions test/jdk/java/lang/Thread/virtual/stress/Skynet.java
Expand Up @@ -21,20 +21,20 @@
* questions.
*/

/**
/*
* @test
* @summary Stress test virtual threads with a variation of the Skynet 1M benchmark
* @requires vm.continuations
* @compile --enable-preview -source ${jdk.version} Skynet.java
* @run main/othervm/timeout=300 --enable-preview Skynet
* @enablePreview
* @run main/othervm/timeout=300 Skynet
*/

/**
/*
* @test
* @requires vm.debug == true & vm.continuations
* @requires vm.gc.Z
* @compile --enable-preview -source ${jdk.version} Skynet.java
* @run main/othervm/timeout=300 --enable-preview -XX:+UnlockDiagnosticVMOptions
* @enablePreview
* @run main/othervm/timeout=300 -XX:+UnlockDiagnosticVMOptions
* -XX:+ZVerifyViews -XX:ZCollectionInterval=0.01 Skynet
*/

Expand All @@ -43,10 +43,9 @@
import java.util.concurrent.ThreadFactory;

public class Skynet {
public static final int ITERATIONS = 10;

public static void main(String[] args) {
for (int i = 0; i < ITERATIONS; i++) {
int iterations = (args.length > 0) ? Integer.parseInt(args[0]) : 10;
for (int i = 0; i < iterations; i++) {
skynet(1_000_000, 499999500000L);
}
}
Expand Down
12 changes: 6 additions & 6 deletions test/jdk/java/lang/Thread/virtual/stress/SleepALot.java
Expand Up @@ -21,19 +21,19 @@
* questions.
*/

/**
/*
* @test
* @summary Stress test Thread.sleep
* @requires vm.debug != true & vm.continuations
* @compile --enable-preview -source ${jdk.version} SleepALot.java
* @run main/othervm --enable-preview SleepALot
* @enablePreview
* @run main/othervm SleepALot 500000
*/

/**
/*
* @test
* @requires vm.debug == true & vm.continuations
* @compile --enable-preview -source ${jdk.version} SleepALot.java
* @run main/othervm/timeout=300 --enable-preview SleepALot 200000
* @enablePreview
* @run main/othervm/timeout=300 SleepALot 200000
*/

import java.time.Duration;
Expand Down
6 changes: 3 additions & 3 deletions test/jdk/java/lang/Thread/virtual/stress/TimedGet.java
Expand Up @@ -21,12 +21,12 @@
* questions.
*/

/**
/*
* @test
* @summary Stress parking with CompletableFuture timed get
* @requires vm.debug != true & vm.continuations
* @compile --enable-preview -source ${jdk.version} TimedGet.java
* @run main/othervm -Xmx1g --enable-preview TimedGet
* @enablePreview
* @run main/othervm -Xmx1g TimedGet 100000
*/

import java.time.Duration;
Expand Down
12 changes: 6 additions & 6 deletions test/jdk/java/lang/Thread/virtual/stress/YieldALot.java
Expand Up @@ -21,19 +21,19 @@
* questions.
*/

/**
/*
* @test
* @summary Stress test Thread.yield
* @requires vm.debug != true
* @compile --enable-preview -source ${jdk.version} YieldALot.java
* @run main/othervm --enable-preview YieldALot
* @enablePreview
* @run main YieldALot 500000
*/

/**
/*
* @test
* @requires vm.debug == true
* @compile --enable-preview -source ${jdk.version} YieldALot.java
* @run main/othervm/timeout=360 --enable-preview YieldALot 200000
* @enablePreview
* @run main YieldALot 200000
*/

import java.time.Duration;
Expand Down
12 changes: 6 additions & 6 deletions test/jdk/java/util/concurrent/ExecutorService/CloseTest.java
Expand Up @@ -25,8 +25,8 @@
* @test
* @summary Test ExecutorService.close, including default implementation
* @library ../lib
* @compile --enable-preview -source ${jdk.version} CloseTest.java
* @run testng/othervm --enable-preview CloseTest
* @enablePreview
* @run testng CloseTest
*/

import java.time.Duration;
Expand Down Expand Up @@ -81,14 +81,14 @@ public void testCloseWithNoTasks(ExecutorService executor) throws Exception {
@Test(dataProvider = "executors")
public void testCloseWithRunningTasks(ExecutorService executor) throws Exception {
Future<?> future = executor.submit(() -> {
Thread.sleep(Duration.ofSeconds(1));
Thread.sleep(Duration.ofMillis(100));
return "foo";
});
executor.close(); // waits for task to complete
assertTrue(executor.isShutdown());
assertTrue(executor.isTerminated());
assertTrue(executor.awaitTermination(10, TimeUnit.MILLISECONDS));
assertEquals(future.get(), "foo");
assertEquals(future.resultNow(), "foo");
}

/**
Expand All @@ -99,7 +99,7 @@ public void testShutdownBeforeClose(ExecutorService executor) throws Exception {
Phaser phaser = new Phaser(2);
Future<?> future = executor.submit(() -> {
phaser.arriveAndAwaitAdvance();
Thread.sleep(Duration.ofSeconds(1));
Thread.sleep(Duration.ofMillis(100));
return "foo";
});
phaser.arriveAndAwaitAdvance(); // wait for task to start
Expand All @@ -110,7 +110,7 @@ public void testShutdownBeforeClose(ExecutorService executor) throws Exception {
assertTrue(executor.isShutdown());
assertTrue(executor.isTerminated());
assertTrue(executor.awaitTermination(10, TimeUnit.MILLISECONDS));
assertEquals(future.get(), "foo");
assertEquals(future.resultNow(), "foo");
}

/**
Expand Down

0 comments on commit b8f9a91

Please sign in to comment.