Uh oh!
There was an error while loading. Please reload this page.
[improvement] add jmh benchmark - #179
Conversation
wenhoujx
commented
Jun 18, 2019
|
| Tracer.fastCompleteSpan(); | ||
| } | ||
| }; | ||
| blackhole.consume(callable.call()); |
There was a problem hiding this comment.
We don't need to blackhole the null result from our callable, however we should blackhole the output, which in this case is a series of Span objects:
Tracer.subscribe("jmh", blackhole::consume);There was a problem hiding this comment.
@carterkozak thanks for CR, does it matter that every call of Tracer.startSpan("span"); starts a span with the same name?
There was a problem hiding this comment.
Spans with the same name are totally fine, we have them in practice via recursive methods ;-)
There was a problem hiding this comment.
good example. do you want each span subscribed by blackhole::consume? which makes the precomputed Callable<Object> becomes a Function<BlackHole, Object> or even Consumer<BlackHole>
There was a problem hiding this comment.
We just need to set the subscriber at the beginning when we get the blackhole instance. Ideally we could configure that globally instead of for each benchmark method, but I’m not sure how. Note that tracing observer registration is a static per jvm, so concurrent measurements will reset the observer
There was a problem hiding this comment.
@carterkozak can i use a UUID as the observer name? so that each invocation has different observer.
There was a problem hiding this comment.
No, you'll end up writing each span to N observers instead of the case we want to benchmark with a single observer.
There was a problem hiding this comment.
I'd start with something along these lines:
@Fork(1)
@Threads(1)
@State(Scope.Benchmark)
@Warmup(iterations = 3, time = 3)
@Measurement(iterations = 3, time = 3)
publicclassSimpleBenchmark {
@Setuppublicvoidsetup(Blackholeblackhole) {
Tracer.subscribe("jmh", blackhole::consume);
Tracer.setSampler(AlwaysSampler.INSTANCE);
}
@TearDownpublicvoidtearDown() {
Tracer.unsubscribe("jmh");
}
@BenchmarkpublicvoidnestedSpans() {
for (inti = 0; i < 100; i++) {
Tracer.startSpan("span");
}
for (inti = 0; i < 100; i++) {
Tracer.fastCompleteSpan();
}
}
}There was a problem hiding this comment.
The sampler can be parameterized so that we can write one benchmark and get results for both the sampled and unsampled cases using parameterized values in state, see the internal class I linked in a DM.
| return NOOP_CALLABLE.call(); | ||
| } finally { | ||
| Tracer.fastCompleteSpan(); | ||
| } |
There was a problem hiding this comment.
Should precompute the callable wrappers.
wenhoujx
commented
Jun 18, 2019
the three benchmarks has similar throughput and gc? i must be doing something wrong: |
| dependencies { | ||
| annotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess' | ||
| compileOnly 'org.openjdk.jmh:jmh-generator-annprocess' | ||
| compile "org.immutables:value::annotations" |
There was a problem hiding this comment.
What about compileOnly + annotationProocessor?
There was a problem hiding this comment.
> Task :tracing-benchmarks:compileJmhJava FAILED
warning: unknown enum constant ImplementationVisibility.PACKAGE
reason: class file for org.immutables.value.Value$Style$ImplementationVisibility not found
warning: unknown enum constant ImplementationVisibility.PACKAGE
error: warnings found and -Werror specified
1 error
2 warnings
the same
carterkozak
commented
Jun 18, 2019
Will take a look in a while. |
wenhoujx
commented
Jun 19, 2019
new benchmark with parameters and |
new benchmark for commit 7d1d92f |
add span benchmarks according to @carterkozak 's comments on #176
remove
Before this PR
After this PR