-
Notifications
You must be signed in to change notification settings - Fork 873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add basic jmh overhead test #3672
Conversation
id("me.champeau.jmh") | ||
id("io.morethan.jmhreport") | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious: why this as String
is needed? It is already clear that this is not null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added 👍
public class ServletBenchmark { | ||
|
||
static { | ||
HelloWorldApplication.main(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering: why do we initialize the app in static {}
and not @Setup
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.