--- old/test/hotspot/jtreg/gc/stress/systemgc/TestSystemGC.java 2017-11-06 21:03:04.071702422 +0100 +++ new/test/hotspot/jtreg/gc/stress/systemgc/TestSystemGC.java 2017-11-06 21:03:03.656689767 +0100 @@ -90,6 +90,7 @@ private long delayMS; SystemGCTask(long delayMS) { +System.err.println("SystemGCTask with delay " + delayMS); this.delayMS = delayMS; } @@ -97,12 +98,14 @@ public void run() { while (!shouldExit()) { System.gc(); - ThreadUtils.sleep(delayMS); + ThreadUtils.sleep(delayMS * 10); } } } public class TestSystemGC { + private static long endTime; + private static final int numGroups = 7; private static final int numGCsPerGroup = 4; @@ -133,8 +136,11 @@ for (int i = 0; i < numGroups; i++) { for (int j = 0; j < numGCsPerGroup; j++) { - System.gc(); - ThreadUtils.sleep(getDelayMS(i)); + System.gc(); + if (System.currentTimeMillis() >= endTime) { + return; + } + ThreadUtils.sleep(getDelayMS(i)); } } } @@ -159,7 +165,8 @@ } private static void runAllPhases() { - for (int i = 0; i < 4; i++) { + int i = 0; + while (i < 4 && System.currentTimeMillis() < endTime) { SystemGCTask gcTask = (i % 2 == 1) ? createSystemGCTask(numGroups / 3) : null; ShortLivedAllocationTask shortTask = @@ -178,15 +185,18 @@ exitTask(longTask); ThreadUtils.sleep(1000); + i++; } } public static void main(String[] args) { + if (args.length > 0) { + int timeout = Integer.parseInt(args[0]) * 1000; + System.out.println("Running with timeout of " + timeout + "ms"); + endTime = System.currentTimeMillis() + timeout; + } // First allocate the long lived objects and then run all phases. populateLongLived(); runAllPhases(); - if (args.length > 0 && args[0].equals("long")) { - runAllPhases(); - } } }