8338512: JFR: Revert changes to TestCodeSweeper
Reviewed-by: mgronlun
This commit is contained in:
parent
6d430f24df
commit
e07a5b6626
@ -743,6 +743,7 @@ jdk/incubator/vector/LoadJsvmlTest.java 8305390 windows-
|
|||||||
|
|
||||||
# jdk_jfr
|
# jdk_jfr
|
||||||
|
|
||||||
|
jdk/jfr/event/compiler/TestCodeSweeper.java 8338127 generic-all
|
||||||
jdk/jfr/event/runtime/TestResidentSetSizeEvent.java 8309846 aix-ppc64
|
jdk/jfr/event/runtime/TestResidentSetSizeEvent.java 8309846 aix-ppc64
|
||||||
jdk/jfr/jvm/TestWaste.java 8282427 generic-all
|
jdk/jfr/jvm/TestWaste.java 8282427 generic-all
|
||||||
|
|
||||||
|
@ -27,11 +27,9 @@ import java.lang.management.MemoryPoolMXBean;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import jdk.jfr.Event;
|
import jdk.jfr.Recording;
|
||||||
import jdk.jfr.consumer.RecordingStream;
|
|
||||||
import jdk.jfr.consumer.RecordedEvent;
|
import jdk.jfr.consumer.RecordedEvent;
|
||||||
import jdk.test.lib.Asserts;
|
import jdk.test.lib.Asserts;
|
||||||
import jdk.test.lib.jfr.EventNames;
|
import jdk.test.lib.jfr.EventNames;
|
||||||
@ -41,7 +39,7 @@ import jdk.test.whitebox.code.BlobType;
|
|||||||
import jdk.test.whitebox.code.CodeBlob;
|
import jdk.test.whitebox.code.CodeBlob;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for events: jdk.CodeCacheFull jdk.CompilationFailure
|
* Test for events: vm/code_cache/full vm/compiler/failure
|
||||||
*
|
*
|
||||||
* We verify that we should get at least one of each of the events listed above.
|
* We verify that we should get at least one of each of the events listed above.
|
||||||
*
|
*
|
||||||
@ -60,15 +58,13 @@ import jdk.test.whitebox.code.CodeBlob;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class TestCodeSweeper {
|
public class TestCodeSweeper {
|
||||||
static class ProvocationEvent extends Event {
|
|
||||||
}
|
|
||||||
private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
|
private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
|
||||||
private static final int COMP_LEVEL_SIMPLE = 1;
|
private static final int COMP_LEVEL_SIMPLE = 1;
|
||||||
private static final int COMP_LEVEL_FULL_OPTIMIZATION = 4;
|
private static final int COMP_LEVEL_FULL_OPTIMIZATION = 4;
|
||||||
private static final int SIZE = 1;
|
private static final int SIZE = 1;
|
||||||
private static final String METHOD_NAME = "verifyFullEvent";
|
private static final String METHOD_NAME = "verifyFullEvent";
|
||||||
private static final String EVENT_CODE_CACHE_FULL = EventNames.CodeCacheFull;
|
private static final String pathFull = EventNames.CodeCacheFull;
|
||||||
private static final String EVENT_COMPILATION_FAILURE = EventNames.CompilationFailure;
|
private static final String pathFailure = EventNames.CompilationFailure;
|
||||||
public static final long SEGMENT_SIZE = WhiteBox.getWhiteBox().getUintxVMFlag("CodeCacheSegmentSize");
|
public static final long SEGMENT_SIZE = WhiteBox.getWhiteBox().getUintxVMFlag("CodeCacheSegmentSize");
|
||||||
public static final long MIN_BLOCK_LENGTH = WhiteBox.getWhiteBox().getUintxVMFlag("CodeCacheMinBlockLength");
|
public static final long MIN_BLOCK_LENGTH = WhiteBox.getWhiteBox().getUintxVMFlag("CodeCacheMinBlockLength");
|
||||||
public static final long MIN_ALLOCATION = SEGMENT_SIZE * MIN_BLOCK_LENGTH;
|
public static final long MIN_ALLOCATION = SEGMENT_SIZE * MIN_BLOCK_LENGTH;
|
||||||
@ -81,41 +77,26 @@ public class TestCodeSweeper {
|
|||||||
System.out.println("This test will warn that the code cache is full.");
|
System.out.println("This test will warn that the code cache is full.");
|
||||||
System.out.println("That is expected and is the purpose of the test.");
|
System.out.println("That is expected and is the purpose of the test.");
|
||||||
System.out.println("************************************************");
|
System.out.println("************************************************");
|
||||||
List<RecordedEvent> events = Collections.synchronizedList(new ArrayList<>());
|
|
||||||
try (RecordingStream rs = new RecordingStream()) {
|
Recording r = new Recording();
|
||||||
rs.setReuse(false);
|
r.enable(pathFull);
|
||||||
rs.enable(EVENT_CODE_CACHE_FULL);
|
r.enable(pathFailure);
|
||||||
rs.enable(EVENT_COMPILATION_FAILURE);
|
r.start();
|
||||||
rs.onEvent(EVENT_CODE_CACHE_FULL, events::add);
|
|
||||||
rs.onEvent(EVENT_COMPILATION_FAILURE, events::add);
|
|
||||||
rs.onEvent(ProvocationEvent.class.getName(), e -> {
|
|
||||||
if (!events.isEmpty()) {
|
|
||||||
rs.close();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Retry if CodeCacheFull or CompilationFailure events weren't provoked
|
|
||||||
try {
|
|
||||||
provokeEvents();
|
provokeEvents();
|
||||||
} catch (Exception ex) {
|
r.stop();
|
||||||
ex.printStackTrace();
|
|
||||||
rs.close();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
rs.startAsync();
|
|
||||||
provokeEvents();
|
|
||||||
rs.awaitTermination();
|
|
||||||
}
|
|
||||||
|
|
||||||
int countEventFull = 0;
|
int countEventFull = 0;
|
||||||
int countEventFailure = 0;
|
int countEventFailure = 0;
|
||||||
|
|
||||||
|
List<RecordedEvent> events = Events.fromRecording(r);
|
||||||
Events.hasEvents(events);
|
Events.hasEvents(events);
|
||||||
for (RecordedEvent event : new ArrayList<>(events)) {
|
for (RecordedEvent event : events) {
|
||||||
switch (event.getEventType().getName()) {
|
switch (event.getEventType().getName()) {
|
||||||
case EVENT_CODE_CACHE_FULL:
|
case pathFull:
|
||||||
countEventFull++;
|
countEventFull++;
|
||||||
verifyFullEvent(event);
|
verifyFullEvent(event);
|
||||||
break;
|
break;
|
||||||
case EVENT_COMPILATION_FAILURE:
|
case pathFailure:
|
||||||
countEventFailure++;
|
countEventFailure++;
|
||||||
verifyFailureEvent(event);
|
verifyFailureEvent(event);
|
||||||
break;
|
break;
|
||||||
@ -134,8 +115,6 @@ public class TestCodeSweeper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void provokeEvents() throws NoSuchMethodException, InterruptedException {
|
private static void provokeEvents() throws NoSuchMethodException, InterruptedException {
|
||||||
System.out.println("provokeEvents()");
|
|
||||||
ProvocationEvent provocationEvent = new ProvocationEvent();
|
|
||||||
// Prepare for later, since we don't want to trigger any compilation
|
// Prepare for later, since we don't want to trigger any compilation
|
||||||
// setting this up.
|
// setting this up.
|
||||||
Method method = TestCodeSweeper.class.getDeclaredMethod(METHOD_NAME, new Class[] { RecordedEvent.class });
|
Method method = TestCodeSweeper.class.getDeclaredMethod(METHOD_NAME, new Class[] { RecordedEvent.class });
|
||||||
@ -180,7 +159,6 @@ public class TestCodeSweeper {
|
|||||||
for (Long blob : blobs) {
|
for (Long blob : blobs) {
|
||||||
WHITE_BOX.freeCodeBlob(blob);
|
WHITE_BOX.freeCodeBlob(blob);
|
||||||
}
|
}
|
||||||
provocationEvent.commit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void verifyFullEvent(RecordedEvent event) throws Throwable {
|
private static void verifyFullEvent(RecordedEvent event) throws Throwable {
|
||||||
|
Loading…
Reference in New Issue
Block a user