Skip to content

Commit 48f7e03

Browse files
breedx-splktrask
andauthored
Improve warmup phase for overhead tests (#5700)
* improve warmup phase for overhead tests * add jfr config file that has just the minimal set of items we care about. * Update benchmark-overhead/src/test/java/io/opentelemetry/OverheadTests.java Co-authored-by: Trask Stalnaker <[email protected]> Co-authored-by: Trask Stalnaker <[email protected]>
1 parent ba3863e commit 48f7e03

File tree

3 files changed

+878
-9
lines changed

3 files changed

+878
-9
lines changed

benchmark-overhead/src/test/java/io/opentelemetry/OverheadTests.java

+18-9
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void runAppOnce(TestConfig config, Agent agent) throws Exception {
8888
writeStartupTimeFile(agent, start);
8989

9090
if (config.getWarmupSeconds() > 0) {
91-
doWarmupPhase(config);
91+
doWarmupPhase(config, petclinic);
9292
}
9393

9494
long testStart = System.currentTimeMillis();
@@ -115,28 +115,37 @@ private void startRecording(Agent agent, GenericContainer<?> petclinic) throws E
115115
"jcmd",
116116
"1",
117117
"JFR.start",
118-
"settings=profile",
118+
"settings=/app/overhead.jfc",
119119
"dumponexit=true",
120120
"name=petclinic",
121121
"filename=" + outFile
122122
};
123123
petclinic.execInContainer(command);
124124
}
125125

126-
private void doWarmupPhase(TestConfig testConfig) {
127-
long start = System.currentTimeMillis();
128-
System.out.println(
129-
"Performing startup warming phase for " + testConfig.getWarmupSeconds() + " seconds...");
130-
while (TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - start)
131-
< testConfig.getWarmupSeconds()) {
126+
private void doWarmupPhase(TestConfig testConfig, GenericContainer<?> petclinic) throws IOException, InterruptedException {
127+
System.out.println("Performing startup warming phase for " + testConfig.getWarmupSeconds() + " seconds...");
128+
129+
// excluding the JFR recording from the warmup causes strange inconsistencies in the results
130+
System.out.println("Starting disposable JFR warmup recording...");
131+
String[] startCommand = {"jcmd", "1", "JFR.start", "settings=/app/overhead.jfc", "dumponexit=true", "name=warmup", "filename=warmup.jfr"};
132+
petclinic.execInContainer(startCommand);
133+
134+
long deadline = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(testConfig.getWarmupSeconds());
135+
while(System.currentTimeMillis() < deadline) {
132136
GenericContainer<?> k6 =
133137
new GenericContainer<>(DockerImageName.parse("loadimpact/k6"))
134138
.withNetwork(NETWORK)
135139
.withCopyFileToContainer(MountableFile.forHostPath("./k6"), "/app")
136-
.withCommand("run", "-u", "5", "-i", "25", "/app/basic.js")
140+
.withCommand("run", "-u", "5", "-i", "200", "/app/basic.js")
137141
.withStartupCheckStrategy(new OneShotStartupCheckStrategy());
138142
k6.start();
139143
}
144+
145+
System.out.println("Stopping disposable JFR warmup recording...");
146+
String[] stopCommand = {"jcmd", "1", "JFR.stop", "name=warmup"};
147+
petclinic.execInContainer(stopCommand);
148+
140149
System.out.println("Warmup complete.");
141150
}
142151

benchmark-overhead/src/test/java/io/opentelemetry/containers/PetClinicRestContainer.java

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ public GenericContainer<?> build() throws Exception {
5757
.withExposedPorts(PETCLINIC_PORT)
5858
.withFileSystemBind(
5959
namingConventions.localResults(), namingConventions.containerResults())
60+
.withCopyFileToContainer(
61+
MountableFile.forClasspathResource("overhead.jfc"), "/app/overhead.jfc")
6062
.waitingFor(Wait.forHttp("/petclinic/actuator/health").forPort(PETCLINIC_PORT))
6163
.withEnv("spring_profiles_active", "postgresql,spring-data-jpa")
6264
.withEnv(

0 commit comments

Comments
 (0)