Add basic jmh overhead test#3672
Add basic jmh overhead test#3672trask merged 8 commits intoopen-telemetry:mainfrom trask:overhead-testing-jmh
Conversation
| id("me.champeau.jmh") | ||
| id("io.morethan.jmhreport") | ||
| } | ||
|
|
There was a problem hiding this comment.
this file is identical copy from opentelemetry-java repo
| // TODO(trask) is this ok? if it's ok, move to otel.jmh-conventions? | ||
| outputs.upToDateWhen { false } |
There was a problem hiding this comment.
gradle experts: is this ok? each time I run jmh task I actually want it to run. using --rerun-tasks takes a long time because it doesn't only rerun this one task
| val copyAgent by registering(Copy::class) { | ||
| into(file("$buildDir/agent")) | ||
| from(configurations.named("agentJar")) | ||
| rename { file: String -> | ||
| file.replace("-$version", "") | ||
| } | ||
|
|
||
| dependsOn(":javaagent:shadowJar") | ||
| } |
There was a problem hiding this comment.
gradle experts: let me know if there is a more preferred way to get the opentelemetry-javaagent-all into a location that the jmh benchmark can depend on
...verhead-jmh/src/jmh/java/io/opentelemetry/javaagent/benchmark/ServletWithAgentBenchmark.java
Outdated
Show resolved
Hide resolved
| profilers.add("gc") | ||
| val jmhIncludeSingleClass: String? by project | ||
| if (jmhIncludeSingleClass != null) { | ||
| includes.add(jmhIncludeSingleClass as String) |
There was a problem hiding this comment.
Just curious: why this as String is needed? It is already clear that this is not null.
There was a problem hiding this comment.
IIRC, the by syntax seems to result in something "dynamic". Seems like it might be a Gradle bug, but it makes kotlin not treat the null check as a type cast.
| profilers.add("gc") | ||
| val jmhIncludeSingleClass: String? by project | ||
| if (jmhIncludeSingleClass != null) { | ||
| includes.add(jmhIncludeSingleClass as String) |
There was a problem hiding this comment.
IIRC, the by syntax seems to result in something "dynamic". Seems like it might be a Gradle bug, but it makes kotlin not treat the null check as a type cast.
|
|
||
| import org.openjdk.jmh.annotations.Fork; | ||
|
|
||
| @Fork(jvmArgsAppend = "-Dotel.javaagent.enabled=false") |
There was a problem hiding this comment.
Just an idea: we could also run a benchmark with -Dotel.javaagent.experimental.use-noop-api=true to see how much overhead is added when no SDK at all is used.
| public class ServletBenchmark { | ||
|
|
||
| static { | ||
| HelloWorldApplication.main(); |
There was a problem hiding this comment.
Just wondering: why do we initialize the app in static {} and not @Setup?
There was a problem hiding this comment.
added comment to explain
// using static initializer instead of @Setup since only want to initialize the app under test
// once regardless of @State and @Threads
|
Just thought about it now, but should we name the dir/module |
ya, I like this, updated |
|
here's a re-run, including the no-op api test: |
I did a bit of profiling, and planning to submit a couple of (micro) optimizations, so want to first submit the test I'm using for profiling/measurement.