-
Notifications
You must be signed in to change notification settings - Fork 848
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrote benchmark tests for the zPages module (#1504)
* Removed URLEncoder * Fixed typo * Added URLDecoding * Included comment for string replacement * Added unit tests for special characters in span names * Resolved URL decoding issues * Moved url decoding to parseQueryMap and updated the corresponding unit tests * Added a README file for zPage quickstart * Add images for README * Updated README * Add frontend images * Add backend images * Added our design doc * Added details on package * Reworded a few lines * Moved DESIGN.md to a docs folder and changed gradle config to implementation * Changed wording regarding HttpServer requirement * Added zpages folder under docs, resolved broken image links * Resolved comments for the design md file * Made a few wording changes * Wrote a benchmark test for TracezSpanBuckets (#23) * Scaffolded logic for basic benchmark tests * Wrote benchmark tests for TracezSpanBuckets * Updated README with benchmark tests * Changed the wording slightly * Updated README file (#25) * Wrote benchmark tests for TracezDataAggregator (#24) * Scaffolded logic for basic benchmark tests * Wrote benchmark tests for TracezSpanBuckets * Updated README with benchmark tests * Changed the wording slightly * Added a set of benchmark tests for TracezDataAggregator * Modified README formatting * Changed benchmark test to negate dead code elimination * Added Javadocs to the TracezDataAggregator benchmark tests * Removed benchmark results from README and added a param to the TracezDataAggregator benchmark tests * Update sdk_extensions/zpages/src/jmh/java/io/opentelemetry/sdk/extensions/zpages/TracezDataAggregatorBenchmark.java Co-authored-by: Anuraag Agrawal <[email protected]> * Added multiple param values for TracezDataAggregatorBenchmark Co-authored-by: Terry Wang <[email protected]> Co-authored-by: Anuraag Agrawal <[email protected]>
- Loading branch information
1 parent
d6d804e
commit bcb1d4a
Showing
4 changed files
with
279 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
166 changes: 166 additions & 0 deletions
166
...es/src/jmh/java/io/opentelemetry/sdk/extensions/zpages/TracezDataAggregatorBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
/* | ||
* 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.trace.Span; | ||
import io.opentelemetry.trace.Status; | ||
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.Param; | ||
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; | ||
import org.openjdk.jmh.infra.Blackhole; | ||
|
||
/** Benchmark class for {@link TracezDataAggregator}. */ | ||
@State(Scope.Benchmark) | ||
public class TracezDataAggregatorBenchmark { | ||
|
||
private static final String runningSpan = "RUNNING_SPAN"; | ||
private static final String latencySpan = "LATENCY_SPAN"; | ||
private static final String errorSpan = "ERROR_SPAN"; | ||
private final Tracer tracer = | ||
OpenTelemetrySdk.getTracerProvider().get("TracezDataAggregatorBenchmark"); | ||
private final TracezSpanProcessor spanProcessor = TracezSpanProcessor.newBuilder().build(); | ||
private final TracezDataAggregator dataAggregator = new TracezDataAggregator(spanProcessor); | ||
|
||
@Param({"1", "10", "1000", "1000000"}) | ||
private int numberOfSpans; | ||
|
||
@Setup(Level.Trial) | ||
public final void setup() { | ||
for (int i = 0; i < numberOfSpans; i++) { | ||
tracer.spanBuilder(runningSpan).startSpan(); | ||
tracer.spanBuilder(latencySpan).startSpan().end(); | ||
Span error = tracer.spanBuilder(errorSpan).startSpan(); | ||
error.setStatus(Status.UNKNOWN); | ||
error.end(); | ||
} | ||
} | ||
|
||
/** Get span counts with 1 thread. */ | ||
@Benchmark | ||
@Threads(value = 1) | ||
@Fork(1) | ||
@Warmup(iterations = 5, time = 1) | ||
@Measurement(iterations = 10, time = 1) | ||
@OutputTimeUnit(TimeUnit.MILLISECONDS) | ||
public void getCounts_01Thread(Blackhole blackhole) { | ||
blackhole.consume(dataAggregator.getRunningSpanCounts()); | ||
blackhole.consume(dataAggregator.getSpanLatencyCounts()); | ||
blackhole.consume(dataAggregator.getErrorSpanCounts()); | ||
} | ||
|
||
/** Get span counts with 5 threads. */ | ||
@Benchmark | ||
@Threads(value = 5) | ||
@Fork(1) | ||
@Warmup(iterations = 5, time = 1) | ||
@Measurement(iterations = 10, time = 1) | ||
@OutputTimeUnit(TimeUnit.MILLISECONDS) | ||
public void getCounts_05Threads(Blackhole blackhole) { | ||
blackhole.consume(dataAggregator.getRunningSpanCounts()); | ||
blackhole.consume(dataAggregator.getSpanLatencyCounts()); | ||
blackhole.consume(dataAggregator.getErrorSpanCounts()); | ||
} | ||
|
||
/** Get span counts with 10 threads. */ | ||
@Benchmark | ||
@Threads(value = 10) | ||
@Fork(1) | ||
@Warmup(iterations = 5, time = 1) | ||
@Measurement(iterations = 10, time = 1) | ||
@OutputTimeUnit(TimeUnit.MILLISECONDS) | ||
public void getCounts_10Threads(Blackhole blackhole) { | ||
blackhole.consume(dataAggregator.getRunningSpanCounts()); | ||
blackhole.consume(dataAggregator.getSpanLatencyCounts()); | ||
blackhole.consume(dataAggregator.getErrorSpanCounts()); | ||
} | ||
|
||
/** Get span counts with 20 threads. */ | ||
@Benchmark | ||
@Threads(value = 20) | ||
@Fork(1) | ||
@Warmup(iterations = 5, time = 1) | ||
@Measurement(iterations = 10, time = 1) | ||
@OutputTimeUnit(TimeUnit.MILLISECONDS) | ||
public void getCounts_20Threads(Blackhole blackhole) { | ||
blackhole.consume(dataAggregator.getRunningSpanCounts()); | ||
blackhole.consume(dataAggregator.getSpanLatencyCounts()); | ||
blackhole.consume(dataAggregator.getErrorSpanCounts()); | ||
} | ||
|
||
/** Get spans with 1 thread. */ | ||
@Benchmark | ||
@Threads(value = 1) | ||
@Fork(1) | ||
@Warmup(iterations = 5, time = 1) | ||
@Measurement(iterations = 10, time = 1) | ||
@OutputTimeUnit(TimeUnit.MILLISECONDS) | ||
public void getSpans_01Thread(Blackhole blackhole) { | ||
blackhole.consume(dataAggregator.getRunningSpans(runningSpan)); | ||
blackhole.consume(dataAggregator.getOkSpans(latencySpan, 0, Long.MAX_VALUE)); | ||
blackhole.consume(dataAggregator.getErrorSpans(errorSpan)); | ||
} | ||
|
||
/** Get spans with 5 threads. */ | ||
@Benchmark | ||
@Threads(value = 5) | ||
@Fork(1) | ||
@Warmup(iterations = 5, time = 1) | ||
@Measurement(iterations = 10, time = 1) | ||
@OutputTimeUnit(TimeUnit.MILLISECONDS) | ||
public void getSpans_05Threads(Blackhole blackhole) { | ||
blackhole.consume(dataAggregator.getRunningSpans(runningSpan)); | ||
blackhole.consume(dataAggregator.getOkSpans(latencySpan, 0, Long.MAX_VALUE)); | ||
blackhole.consume(dataAggregator.getErrorSpans(errorSpan)); | ||
} | ||
|
||
/** Get spans with 10 threads. */ | ||
@Benchmark | ||
@Threads(value = 10) | ||
@Fork(1) | ||
@Warmup(iterations = 5, time = 1) | ||
@Measurement(iterations = 10, time = 1) | ||
@OutputTimeUnit(TimeUnit.MILLISECONDS) | ||
public void getSpans_10Threads(Blackhole blackhole) { | ||
blackhole.consume(dataAggregator.getRunningSpans(runningSpan)); | ||
blackhole.consume(dataAggregator.getOkSpans(latencySpan, 0, Long.MAX_VALUE)); | ||
blackhole.consume(dataAggregator.getErrorSpans(errorSpan)); | ||
} | ||
|
||
/** Get spans with 20 threads. */ | ||
@Benchmark | ||
@Threads(value = 20) | ||
@Fork(1) | ||
@Warmup(iterations = 5, time = 1) | ||
@Measurement(iterations = 10, time = 1) | ||
@OutputTimeUnit(TimeUnit.MILLISECONDS) | ||
public void getSpans_20Threads(Blackhole blackhole) { | ||
blackhole.consume(dataAggregator.getRunningSpans(runningSpan)); | ||
blackhole.consume(dataAggregator.getOkSpans(latencySpan, 0, Long.MAX_VALUE)); | ||
blackhole.consume(dataAggregator.getErrorSpans(errorSpan)); | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
...pages/src/jmh/java/io/opentelemetry/sdk/extensions/zpages/TracezSpanBucketsBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* 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; | ||
|
||
/** Benchmark class for {@link TracezSpanBuckets}. */ | ||
@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); | ||
} | ||
} |