mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
8364756: JFR: Improve slow tests
Reviewed-by: mgronlun
This commit is contained in:
parent
d023982600
commit
87d734012e
@ -26,6 +26,7 @@ package jdk.jfr.api.consumer.streaming;
|
||||
import java.util.Random;
|
||||
|
||||
import jdk.jfr.Event;
|
||||
import jdk.jfr.StackTrace;
|
||||
import jdk.jfr.consumer.RecordingStream;
|
||||
|
||||
/**
|
||||
@ -38,6 +39,7 @@ import jdk.jfr.consumer.RecordingStream;
|
||||
*/
|
||||
public class TestFilledChunks {
|
||||
|
||||
@StackTrace(false)
|
||||
static class FillEvent extends Event {
|
||||
String message;
|
||||
int value;
|
||||
|
||||
@ -44,7 +44,7 @@ import jdk.jfr.consumer.RecordingStream;
|
||||
*/
|
||||
public class TestStartMultiChunk {
|
||||
|
||||
@Period("10 s")
|
||||
@Period("2 s")
|
||||
@Name("Zebra")
|
||||
static class ZebraEvent extends Event {
|
||||
}
|
||||
@ -65,7 +65,7 @@ public class TestStartMultiChunk {
|
||||
CountDownLatch dogLatch = new CountDownLatch(1);
|
||||
CountDownLatch catLatch = new CountDownLatch(1);
|
||||
CountDownLatch mouseLatch = new CountDownLatch(1);
|
||||
CountDownLatch zebraLatch = new CountDownLatch(3);
|
||||
CountDownLatch zebraLatch = new CountDownLatch(2);
|
||||
|
||||
FlightRecorder.addPeriodicEvent(ZebraEvent.class, () -> {
|
||||
ZebraEvent ze = new ZebraEvent();
|
||||
|
||||
@ -52,7 +52,7 @@ import jdk.test.lib.thread.XRun;
|
||||
*/
|
||||
public class StressJavaMonitorEvents {
|
||||
|
||||
static final int RUN_TIME_MS = 10000;
|
||||
static final int RUN_TIME_MS = 5000;
|
||||
static final int GC_EVERY_MS = 500;
|
||||
static final int THREADS = 4;
|
||||
static final int NUM_LOCKS = 1024;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -33,6 +33,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.management.MBeanServerConnection;
|
||||
|
||||
import jdk.jfr.Event;
|
||||
import jdk.jfr.StackTrace;
|
||||
import jdk.management.jfr.RemoteRecordingStream;
|
||||
|
||||
/**
|
||||
@ -45,6 +46,7 @@ import jdk.management.jfr.RemoteRecordingStream;
|
||||
*/
|
||||
public class TestMaxSize {
|
||||
|
||||
@StackTrace(false)
|
||||
static class Monkey extends Event {
|
||||
}
|
||||
|
||||
@ -92,7 +94,7 @@ public class TestMaxSize {
|
||||
m.commit();
|
||||
}
|
||||
System.out.println("Emitted " + count + " events");
|
||||
Thread.sleep(1000);
|
||||
Thread.sleep(100);
|
||||
}
|
||||
|
||||
private static int fileCount(Path dir) throws IOException {
|
||||
|
||||
@ -97,7 +97,7 @@ public class TestRemoteDump {
|
||||
}
|
||||
}
|
||||
|
||||
private static List<RecordedEvent> recordWithPolicy(String filename, Consumer<RemoteRecordingStream> policy) throws Exception {
|
||||
private static List<RecordedEvent> recordWithPolicy(String filename, boolean awaitEvents, Consumer<RemoteRecordingStream> policy) throws Exception {
|
||||
CountDownLatch latch1 = new CountDownLatch(1);
|
||||
CountDownLatch latch2 = new CountDownLatch(2);
|
||||
CountDownLatch latch3 = new CountDownLatch(3);
|
||||
@ -111,14 +111,18 @@ public class TestRemoteDump {
|
||||
rs.startAsync();
|
||||
DumpEvent e1 = new DumpEvent();
|
||||
e1.commit();
|
||||
latch1.await();
|
||||
if (awaitEvents) {
|
||||
latch1.await();
|
||||
}
|
||||
// Force chunk rotation
|
||||
try (Recording r = new Recording()) {
|
||||
r.start();
|
||||
DumpEvent e2 = new DumpEvent();
|
||||
e2.commit();
|
||||
}
|
||||
latch2.await();
|
||||
if (awaitEvents) {
|
||||
latch2.await();
|
||||
}
|
||||
DumpEvent e3 = new DumpEvent();
|
||||
e3.commit();
|
||||
latch3.await();
|
||||
@ -129,7 +133,7 @@ public class TestRemoteDump {
|
||||
}
|
||||
|
||||
private static void testSetMaxSize() throws Exception {
|
||||
var events = recordWithPolicy("max-size.jfr", rs -> {
|
||||
var events = recordWithPolicy("max-size.jfr", false, rs -> {
|
||||
// keeps all events for the dump
|
||||
rs.setMaxSize(100_000_000);
|
||||
});
|
||||
@ -140,7 +144,7 @@ public class TestRemoteDump {
|
||||
}
|
||||
|
||||
private static void testSetMaxAge() throws Exception {
|
||||
var events = recordWithPolicy("max-age.jfr", rs -> {
|
||||
var events = recordWithPolicy("max-age.jfr", false, rs -> {
|
||||
// keeps all events for the dump
|
||||
rs.setMaxAge(Duration.ofDays(1));
|
||||
});
|
||||
@ -151,7 +155,7 @@ public class TestRemoteDump {
|
||||
}
|
||||
|
||||
private static void testSetNoPolicy() throws Exception {
|
||||
var events = recordWithPolicy("no-policy.jfr", rs -> {
|
||||
var events = recordWithPolicy("no-policy.jfr", true, rs -> {
|
||||
// use default policy, remove after consumption
|
||||
});
|
||||
// Since latch3 have been triggered at least two events/chunks
|
||||
|
||||
@ -61,7 +61,7 @@ public class TestWaste {
|
||||
try (Recording r = new Recording(c)) {
|
||||
// Old objects that are cleared out should not create waste
|
||||
r.enable("jdk.OldObjectSample")
|
||||
.with("cutoff", "infinity")
|
||||
.with("cutoff", "2 s")
|
||||
.withStackTrace();
|
||||
// No stack trace waste from allocation sample
|
||||
r.enable("jdk.ObjectAllocationSample")
|
||||
|
||||
@ -74,13 +74,6 @@ public class TestMultipleStartupRecordings {
|
||||
test(pb, "Started recording 1", "Started recording 2", "Started recording 3");
|
||||
}
|
||||
|
||||
private static void testDefault() throws Exception {
|
||||
System.out.println("testDefault");
|
||||
launchUnary(null);
|
||||
launchBinary(null, null);
|
||||
launchTernary(null, null, null);
|
||||
}
|
||||
|
||||
private static void testColonDelimited() throws Exception {
|
||||
launchBinary(":name=myrecording1,filename=myrecording1.jfr", ":filename=myrecording2.jfr,name=myrecording2");
|
||||
}
|
||||
@ -99,7 +92,6 @@ public class TestMultipleStartupRecordings {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
testDefault();
|
||||
testColonDelimited();
|
||||
testMixed();
|
||||
testWithFlightRecorderOptions();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user