Skip to content

Commit 7d255d1

Browse files
authored
Run warmup phase and allow concurrency configuration (#95)
In this commit we are enabling the warmup phase and allowing runs to have configurable concurrency. Also improved the commands provided in the README. Testing: ``` OverheadTests > runAllTestConfigurations() > all-800-tps STANDARD_OUT ---------------------------------------------------------- Run at Mon Mar 04 20:42:29 UTC 2024 all-800-tps : Compares all DistroConfigs (800TPS test) 100 users, 1s duration ---------------------------------------------------------- DistroConfig : none app_signals_disabled app_signals_no_traces app_signals_traces Run duration : 00:00:13 00:00:11 00:00:13 00:00:11 Avg. CPU (user) % : 0.0 0.0 0.0 0.0 Max. CPU (user) % : 0.0 0.0 0.0 0.0 Avg. mch tot cpu % : 0.0 0.0 0.0 0.0 Startup time (ms) : 4010 5013 5014 5013 Total allocated MB : 0.00 0.00 0.00 0.00 Thread switch rate : 0.0 0.0 0.0 0.0 GC time (ms) : 0 0 0 0 GC pause time (ms) : 0 0 0 0 Req. Count : 1400.00 1400.00 1400.00 1400.00 Req. Rate : 124.01 144.99 119.48 146.53 Req. Lat. mean (ms) : 481.05 462.39 509.49 504.60 Req. Lat. p0 (ms) : 2.06 2.85 2.08 4.23 Req. Lat. p50 (ms) : 159.19 190.15 175.91 200.18 Req. Lat. p90 (ms) : 1143.15 1303.96 1391.22 1427.85 Req. Lat. p99 (ms) : 5058.14 3840.13 4229.97 4261.41 Req. Lat. p100 (ms) : 8397.74 5530.18 8578.33 5468.59 Net read avg (bps) : 0.00 0.00 0.00 0.00 Net write avg (bps) : 0.00 0.00 0.00 0.00 Peak threads : 0 0 0 0 Gradle Test Executor 41 finished executing tests. > Task :test Finished generating test XML results (0.145 secs) into: /workplace/thp/python-sdk/aws-otel-python-instrumentation/performance-tests/build/test-results/test Generating HTML test report... Finished generating test html results (0.106 secs) into: /workplace/thp/python-sdk/aws-otel-python-instrumentation/performance-tests/build/reports/tests/test Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0. You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins. For more on this, please refer to https://docs.gradle.org/8.6/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation. BUILD SUCCESSFUL in 6m 49s 4 actionable tasks: 4 executed ``` By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent a10d220 commit 7d255d1

File tree

4 files changed

+38
-42
lines changed

4 files changed

+38
-42
lines changed

performance-tests/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,17 @@ Pre-requirements:
8080
* Have `docker` installed and running - verify by running the `docker` command.
8181
* Export `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_SESSION_TOKEN`, and `S3_BUCKET` environment variables.
8282
* By default, each distroConfig runs for 10 seconds. To change this, export `DURATION` environment variable (e.g. `60m`).
83+
* By default, each distroConfig runs with a concurrency (VUs) of 5. To change this, export `CONCURRENCY` environment variable (e.g. `10`).
8384

8485
Steps:
8586
* From `aws-otel-python-instrumentation` dir, execute:
8687
```sh
8788
./scripts/build_and_install_distro.sh
8889
./scripts/set-up-performance-tests.sh
8990
cd performance-tests
90-
./gradlew test
91+
./gradlew clean test
9192
```
9293

9394
The last step can be run or you can run from IDE (after setting environment variables appropriately).
9495

95-
To diagnose test failures with `./gradlew -i test` or use `-d` for very fine details.
96+
To diagnose test failures with `./gradlew -i clean test` or use `-d` for very fine details.

performance-tests/src/test/java/io/opentelemetry/OverheadTests.java

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
import java.io.IOException;
2626
import java.nio.file.Files;
2727
import java.nio.file.Path;
28+
import java.time.Duration;
2829
import java.util.HashMap;
2930
import java.util.List;
3031
import java.util.Map;
31-
import java.util.concurrent.TimeUnit;
3232
import java.util.stream.Stream;
3333
import org.junit.jupiter.api.AfterAll;
3434
import org.junit.jupiter.api.BeforeAll;
@@ -108,8 +108,9 @@ void runAppOnce(TestConfig config, DistroConfig distroConfig) throws Exception {
108108

109109
populateDatabase();
110110

111-
if (config.getWarmupSeconds() > 0) {
112-
// doWarmupPhase(config, vehicleInventoryService);
111+
int warmupSeconds = config.getWarmupSeconds();
112+
if (warmupSeconds > 0) {
113+
doWarmupPhase(warmupSeconds);
113114
}
114115

115116
long testStart = System.currentTimeMillis();
@@ -142,40 +143,22 @@ private void startRecording(
142143
vehicleInventoryService.execInContainer(command);
143144
}
144145

145-
private void doWarmupPhase(TestConfig testConfig, GenericContainer<?> vehicleInventoryService)
146-
throws IOException, InterruptedException {
147-
System.out.println(
148-
"Performing startup warming phase for " + testConfig.getWarmupSeconds() + " seconds...");
149-
150-
// excluding the JFR recording from the warmup causes strange inconsistencies in the results
151-
System.out.println("Starting disposable JFR warmup recording...");
152-
String[] startCommand = {
153-
"jcmd",
154-
"1",
155-
"JFR.start",
156-
"settings=/app/overhead.jfc",
157-
"dumponexit=true",
158-
"name=warmup",
159-
"filename=warmup.jfr"
160-
};
161-
vehicleInventoryService.execInContainer(startCommand);
162-
163-
long deadline =
164-
System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(testConfig.getWarmupSeconds());
165-
while (System.currentTimeMillis() < deadline) {
166-
GenericContainer<?> k6 =
167-
new GenericContainer<>(DockerImageName.parse("loadimpact/k6"))
168-
.withNetwork(NETWORK)
169-
.withCopyFileToContainer(MountableFile.forHostPath("./k6"), "/app")
170-
.withCommand("run", "-u", "5", "-i", "200", "/app/basic.js")
171-
.withStartupCheckStrategy(new OneShotStartupCheckStrategy());
172-
k6.start();
146+
private void doWarmupPhase(int seconds) {
147+
System.out.println("Performing warm up phase for " + seconds + " seconds.");
148+
GenericContainer<?> k6 =
149+
new GenericContainer<>(DockerImageName.parse("loadimpact/k6"))
150+
.withNetwork(NETWORK)
151+
.withCopyFileToContainer(MountableFile.forHostPath("./k6"), "/app")
152+
.withCommand("run", "-u", "5", "-d", seconds + "s", "/app/performanceTest.js")
153+
.withStartupCheckStrategy(
154+
new OneShotStartupCheckStrategy().withTimeout(Duration.ofSeconds(seconds * 2L)));
155+
k6.start();
156+
sleep(seconds);
157+
System.out.println("Awaiting warmup phase end.");
158+
while (k6.isRunning()) {
159+
System.out.println("Warmup still running.");
160+
sleep(1);
173161
}
174-
175-
System.out.println("Stopping disposable JFR warmup recording...");
176-
String[] stopCommand = {"jcmd", "1", "JFR.stop", "name=warmup"};
177-
vehicleInventoryService.execInContainer(stopCommand);
178-
179162
System.out.println("Warmup complete.");
180163
}
181164

@@ -194,4 +177,12 @@ private void writeStartupTimeFile(DistroConfig distroConfig, long start) throws
194177
Path startupPath = namingConventions.local.startupDurationFile(distroConfig);
195178
Files.writeString(startupPath, String.valueOf(delta));
196179
}
180+
181+
private static void sleep(int seconds) {
182+
try {
183+
Thread.sleep(seconds * 1000L);
184+
} catch (InterruptedException e) {
185+
throw new RuntimeException(e);
186+
}
187+
}
197188
}

performance-tests/src/test/java/io/opentelemetry/config/Configs.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,20 @@ public enum Configs {
1717
.name("all-100-tps")
1818
.description("Compares all DistroConfigs (100TPS test)")
1919
.withDistroConfigs(DistroConfig.values())
20-
.warmupSeconds(60)
20+
.warmupSeconds(10)
2121
.maxRequestRate(100)
2222
.duration(System.getenv("DURATION"))
23+
.concurrentConnections(System.getenv("CONCURRENCY"))
2324
.build()),
2425
ALL_800_TPS(
2526
TestConfig.builder()
2627
.name("all-800-tps")
2728
.description("Compares all DistroConfigs (800TPS test)")
2829
.withDistroConfigs(DistroConfig.values())
29-
.warmupSeconds(60)
30+
.warmupSeconds(10)
3031
.maxRequestRate(800)
3132
.duration(System.getenv("DURATION"))
33+
.concurrentConnections(System.getenv("CONCURRENCY"))
3234
.build());
3335

3436
public final TestConfig config;

performance-tests/src/test/java/io/opentelemetry/config/TestConfig.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@ Builder maxRequestRate(int maxRequestRate) {
9898
return this;
9999
}
100100

101-
Builder concurrentConnections(int concurrentConnections) {
102-
this.concurrentConnections = concurrentConnections;
101+
Builder concurrentConnections(String concurrentConnections) {
102+
if (concurrentConnections != null && !concurrentConnections.isEmpty()) {
103+
this.concurrentConnections = Integer.parseInt(concurrentConnections);
104+
}
103105
return this;
104106
}
105107

0 commit comments

Comments
 (0)