Skip to content
Permalink
Browse files
8167015: compiler/codecache/jmx/PoolsIndependenceTest.java timeout
Reviewed-by: kvn, thartmann
  • Loading branch information
Evgeny Nikitin authored and TobiHartmann committed Mar 23, 2021
1 parent df01b15 commit 0b03d0479254c89196fad1b6b22ac411bebb2273
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
@@ -41,7 +41,6 @@
# :hotspot_compiler

compiler/ciReplay/TestSAServer.java 8029528 generic-all
compiler/codecache/jmx/PoolsIndependenceTest.java 8167015 generic-all
compiler/compilercontrol/jcmd/ClearDirectivesFileStackTest.java 8225370 generic-all
compiler/jvmci/compilerToVM/GetFlagValueTest.java 8204459 generic-all
compiler/tiered/LevelTransitionTest.java 8067651 generic-all
@@ -57,11 +57,16 @@
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;

import jtreg.SkippedException;

public class PoolsIndependenceTest implements NotificationListener {

private final Map<String, AtomicInteger> counters;
private final BlobType btype;
private volatile long lastEventTimestamp;
private volatile long maxUsageRegistered;
private final long TEST_TIMEOUT_LIMIT = System.currentTimeMillis() +
Utils.adjustTimeout(Utils.DEFAULT_TEST_TIMEOUT) - 5_000; // 5 seconds allowance is arbitrary

public PoolsIndependenceTest(BlobType btype) {
counters = new HashMap<>();
@@ -70,6 +75,7 @@ public PoolsIndependenceTest(BlobType btype) {
}
this.btype = btype;
lastEventTimestamp = 0;
maxUsageRegistered = 0;
CodeCacheUtils.disableCollectionUsageThresholds();
}

@@ -81,17 +87,25 @@ public static void main(String[] args) {

protected void runTest() {
MemoryPoolMXBean bean = btype.getMemoryPool();
System.out.printf("INFO: Starting scenario with %s%n", bean.getName());
((NotificationEmitter) ManagementFactory.getMemoryMXBean()).
addNotificationListener(this, null, null);
bean.setUsageThreshold(bean.getUsage().getUsed() + 1);
final long usageThresholdLimit = bean.getUsage().getUsed() + 1;
bean.setUsageThreshold(usageThresholdLimit);

long beginTimestamp = System.currentTimeMillis();
final long phaseTimeout = Math.min(TEST_TIMEOUT_LIMIT,
beginTimestamp + 20_000); // 20 seconds is enought for everybody.

CodeCacheUtils.WB.allocateCodeBlob(
CodeCacheUtils.ALLOCATION_SIZE, btype.id);
CodeCacheUtils.WB.fullGC();

/* waiting for expected event to be received plus double the time took
to receive expected event(for possible unexpected) and
plus 1 second in case expected event received (almost)immediately */
Utils.waitForCondition(() -> {
maxUsageRegistered = Math.max(bean.getUsage().getUsed(), maxUsageRegistered);
long currentTimestamp = System.currentTimeMillis();
int eventsCount
= counters.get(btype.getMemoryPool().getName()).get();
@@ -100,10 +114,25 @@ to receive expected event(for possible unexpected) and
return true;
}
long timeLastEventTook
= beginTimestamp - lastEventTimestamp;
long timeoutValue
= lastEventTimestamp - beginTimestamp;

long awaitForUnexpectedTimeout
= 1000L + beginTimestamp + 3L * timeLastEventTook;
return currentTimestamp > timeoutValue;

return currentTimestamp > Math.min(phaseTimeout, awaitForUnexpectedTimeout);
};

if (currentTimestamp > phaseTimeout) {
if (maxUsageRegistered < usageThresholdLimit) {
throw new SkippedException("The code cache usage hasn't exceeded" +
" the limit of " + usageThresholdLimit +
" (max usage reached is " + maxUsageRegistered + ")" +
" within test timeouts, can't test notifications");
} else {
Asserts.fail("UsageThresholdLimit was set to " + usageThresholdLimit +
", max usage of " + maxUsageRegistered + " have been registered" +
", but no notifications issued");
}
}
return false;
});

0 comments on commit 0b03d04

Please sign in to comment.