< prev index next >
test/hotspot/jtreg/gc/stress/systemgc/TestSystemGC.java
Print this page
rev 47694 : imported patch 8190703-testsystemgc-timeout
*** 88,110 ****
class SystemGCTask extends Exitable implements Runnable {
private long delayMS;
SystemGCTask(long delayMS) {
this.delayMS = delayMS;
}
@Override
public void run() {
while (!shouldExit()) {
System.gc();
! ThreadUtils.sleep(delayMS);
}
}
}
public class TestSystemGC {
private static final int numGroups = 7;
private static final int numGCsPerGroup = 4;
private static Map<String, String> longLivedMap = new TreeMap<>();
--- 88,113 ----
class SystemGCTask extends Exitable implements Runnable {
private long delayMS;
SystemGCTask(long delayMS) {
+ System.err.println("SystemGCTask with delay " + delayMS);
this.delayMS = delayMS;
}
@Override
public void run() {
while (!shouldExit()) {
System.gc();
! ThreadUtils.sleep(delayMS * 10);
}
}
}
public class TestSystemGC {
+ private static long endTime;
+
private static final int numGroups = 7;
private static final int numGCsPerGroup = 4;
private static Map<String, String> longLivedMap = new TreeMap<>();
*** 132,141 ****
--- 135,147 ----
ThreadUtils.sleep(1000);
for (int i = 0; i < numGroups; i++) {
for (int j = 0; j < numGCsPerGroup; j++) {
System.gc();
+ if (System.currentTimeMillis() >= endTime) {
+ return;
+ }
ThreadUtils.sleep(getDelayMS(i));
}
}
}
*** 157,167 ****
task.exit();
}
}
private static void runAllPhases() {
! for (int i = 0; i < 4; i++) {
SystemGCTask gcTask =
(i % 2 == 1) ? createSystemGCTask(numGroups / 3) : null;
ShortLivedAllocationTask shortTask =
(i == 1 || i == 3) ? new ShortLivedAllocationTask() : null;
LongLivedAllocationTask longTask =
--- 163,174 ----
task.exit();
}
}
private static void runAllPhases() {
! int i = 0;
! while (i < 4 && System.currentTimeMillis() < endTime) {
SystemGCTask gcTask =
(i % 2 == 1) ? createSystemGCTask(numGroups / 3) : null;
ShortLivedAllocationTask shortTask =
(i == 1 || i == 3) ? new ShortLivedAllocationTask() : null;
LongLivedAllocationTask longTask =
*** 176,192 ****
exitTask(gcTask);
exitTask(shortTask);
exitTask(longTask);
ThreadUtils.sleep(1000);
}
}
public static void main(String[] args) {
// First allocate the long lived objects and then run all phases.
populateLongLived();
runAllPhases();
- if (args.length > 0 && args[0].equals("long")) {
- runAllPhases();
- }
}
}
--- 183,202 ----
exitTask(gcTask);
exitTask(shortTask);
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();
}
}
< prev index next >