Skip to content
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

Wrote a benchmark test for TracezSpanBuckets #23

Merged
merged 5 commits into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion sdk_extensions/zpages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,51 @@ details. For example, here are the details of the `ChildSpan` latency sample (ro
The /traceconfigz zPage displays information about the currently active tracing configuration and
provides an interface for users to modify relevant parameters. Here is what the web page looks like:

![traceconfigz](img/traceconfigz.png)
![traceconfigz](img/traceconfigz.png)

## Benchmark Testing

This module contains a set of benchmark tests for adding spans to an instance of TracezSpanBuckets.
You can run the tests yourself with the following command:

```
./gradlew -PjmhIncludeSingleClass=TracezSpanBucketsBenchmark clean :opentelemetry-sdk-extension-zpages:jmh
```

Below is a summary of the expected results:

```
Benchmark Mode Cnt Score Error Units

TracezSpanBucketsBenchmark.addToBucket_01Thread thrpt 10 17133.815 ± 179.117 ops/ms
TracezSpanBucketsBenchmark.addToBucket_01Thread:·gc.alloc.rate thrpt 10 609.617 ± 6.356 MB/sec
TracezSpanBucketsBenchmark.addToBucket_01Thread:·gc.alloc.rate.norm thrpt 10 56.000 ± 0.001 B/op
TracezSpanBucketsBenchmark.addToBucket_01Thread:·gc.churn.G1_Eden_Space thrpt 10 630.842 ± 502.667 MB/sec
TracezSpanBucketsBenchmark.addToBucket_01Thread:·gc.churn.G1_Eden_Space.norm thrpt 10 57.967 ± 46.195 B/op
TracezSpanBucketsBenchmark.addToBucket_01Thread:·gc.count thrpt 10 8.000 counts
TracezSpanBucketsBenchmark.addToBucket_01Thread:·gc.time thrpt 10 37.000 ms

TracezSpanBucketsBenchmark.addToBucket_05Threads thrpt 10 1448.734 ± 59.915 ops/ms
TracezSpanBucketsBenchmark.addToBucket_05Threads:·gc.alloc.rate thrpt 10 88.369 ± 3.629 MB/sec
TracezSpanBucketsBenchmark.addToBucket_05Threads:·gc.alloc.rate.norm thrpt 10 96.002 ± 0.001 B/op
TracezSpanBucketsBenchmark.addToBucket_05Threads:·gc.churn.G1_Eden_Space thrpt 10 78.812 ± 376.794 MB/sec
TracezSpanBucketsBenchmark.addToBucket_05Threads:·gc.churn.G1_Eden_Space.norm thrpt 10 85.257 ± 407.608 B/op
TracezSpanBucketsBenchmark.addToBucket_05Threads:·gc.count thrpt 10 1.000 counts
TracezSpanBucketsBenchmark.addToBucket_05Threads:·gc.time thrpt 10 6.000 ms

TracezSpanBucketsBenchmark.addToBucket_10Threads thrpt 10 2435.441 ± 49.773 ops/ms
TracezSpanBucketsBenchmark.addToBucket_10Threads:·gc.alloc.rate thrpt 10 148.482 ± 3.023 MB/sec
TracezSpanBucketsBenchmark.addToBucket_10Threads:·gc.alloc.rate.norm thrpt 10 96.002 ± 0.001 B/op
TracezSpanBucketsBenchmark.addToBucket_10Threads:·gc.churn.G1_Eden_Space thrpt 10 157.433 ± 501.783 MB/sec
TracezSpanBucketsBenchmark.addToBucket_10Threads:·gc.churn.G1_Eden_Space.norm thrpt 10 102.915 ± 328.063 B/op
TracezSpanBucketsBenchmark.addToBucket_10Threads:·gc.count thrpt 10 2.000 counts
TracezSpanBucketsBenchmark.addToBucket_10Threads:·gc.time thrpt 10 12.000 ms

TracezSpanBucketsBenchmark.addToBucket_20Threads thrpt 10 2355.800 ± 140.500 ops/ms
TracezSpanBucketsBenchmark.addToBucket_20Threads:·gc.alloc.rate thrpt 10 143.503 ± 8.528 MB/sec
TracezSpanBucketsBenchmark.addToBucket_20Threads:·gc.alloc.rate.norm thrpt 10 96.004 ± 0.001 B/op
TracezSpanBucketsBenchmark.addToBucket_20Threads:·gc.churn.G1_Eden_Space thrpt 10 157.130 ± 500.816 MB/sec
TracezSpanBucketsBenchmark.addToBucket_20Threads:·gc.churn.G1_Eden_Space.norm thrpt 10 106.904 ± 340.741 B/op
TracezSpanBucketsBenchmark.addToBucket_20Threads:·gc.count thrpt 10 2.000 counts
TracezSpanBucketsBenchmark.addToBucket_20Threads:·gc.time thrpt 10 10.000 ms
```
8 changes: 8 additions & 0 deletions sdk_extensions/zpages/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id "java"
id "maven-publish"

id "me.champeau.gradle.jmh"
id "ru.vyarus.animalsniffer"
}

Expand All @@ -17,3 +18,10 @@ dependencies {

signature "org.codehaus.mojo.signature:java17:1.0@signature"
}

animalsniffer {
// Don't check sourceSets.jmh and sourceSets.test
sourceSets = [
sourceSets.main
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Copyright 2020, OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.opentelemetry.sdk.extensions.zpages;

import io.opentelemetry.sdk.OpenTelemetrySdk;
import io.opentelemetry.sdk.trace.ReadableSpan;
import io.opentelemetry.trace.Span;
import io.opentelemetry.trace.Tracer;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.annotations.Warmup;

@State(Scope.Benchmark)
public class TracezSpanBucketsBenchmark {

private static final String spanName = "BENCHMARK_SPAN";
private static ReadableSpan readableSpan;
private TracezSpanBuckets bucket;

@Setup(Level.Trial)
public final void setup() {
bucket = new TracezSpanBuckets();
Tracer tracer = OpenTelemetrySdk.getTracerProvider().get("TracezZPageBenchmark");
Span span = tracer.spanBuilder(spanName).startSpan();
span.end();
readableSpan = (ReadableSpan) span;
}

@Benchmark
@Threads(value = 1)
@Fork(1)
@Warmup(iterations = 5, time = 1)
@Measurement(iterations = 10, time = 1)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void addToBucket_01Thread() {
bucket.addToBucket(readableSpan);
}

@Benchmark
@Threads(value = 5)
@Fork(1)
@Warmup(iterations = 5, time = 1)
@Measurement(iterations = 10, time = 1)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void addToBucket_05Threads() {
bucket.addToBucket(readableSpan);
}

@Benchmark
@Threads(value = 10)
@Fork(1)
@Warmup(iterations = 5, time = 1)
@Measurement(iterations = 10, time = 1)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void addToBucket_10Threads() {
bucket.addToBucket(readableSpan);
}

@Benchmark
@Threads(value = 20)
@Fork(1)
@Warmup(iterations = 5, time = 1)
@Measurement(iterations = 10, time = 1)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void addToBucket_20Threads() {
bucket.addToBucket(readableSpan);
}
}