From fdd8c89e83771486959fa6852f2395317c9936f8 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 12 Apr 2024 13:50:09 -1000 Subject: [PATCH] benchmarks: moves dependency scope to test except wire Signed-off-by: Adrian Cole --- benchmarks/README.md | 19 ++- benchmarks/pom.xml | 147 +++++++++++++----- benchmarks/src/test/assembly/test-jar.xml | 35 +++++ .../java/zipkin2/EndpointBenchmarks.java | 0 .../java/zipkin2/SpanBenchmarks.java | 0 .../java/zipkin2/codec/CodecBenchmarks.java | 0 .../zipkin2/codec/JacksonSpanDecoder.java | 0 .../zipkin2/codec/JsonCodecBenchmarks.java | 0 .../java/zipkin2/codec/MoshiSpanDecoder.java | 1 - .../zipkin2/codec/ProtoCodecBenchmarks.java | 0 .../zipkin2/codec/ProtobufSpanDecoder.java | 0 .../java/zipkin2/codec/WireSpanDecoder.java | 2 +- .../zipkin2/collector/MetricsBenchmarks.java | 5 +- .../internal/BulkRequestBenchmarks.java | 0 .../internal/DelayLimiterBenchmarks.java | 0 .../internal/ReadBufferBenchmarks.java | 0 .../internal/WriteBufferBenchmarks.java | 0 .../server/ServerIntegratedBenchmark.java | 15 +- .../throttle/ThrottledCallBenchmarks.java | 0 .../src/test/resources/log4j2.properties | 9 -- .../test/resources/simplelogger.properties | 9 ++ .../resources/zipkin2-chinese.json | 0 .../resources/zipkin2-client.json | 0 pom.xml | 4 +- zipkin-server/pom.xml | 2 +- 25 files changed, 179 insertions(+), 69 deletions(-) create mode 100644 benchmarks/src/test/assembly/test-jar.xml rename benchmarks/src/{main => test}/java/zipkin2/EndpointBenchmarks.java (100%) rename benchmarks/src/{main => test}/java/zipkin2/SpanBenchmarks.java (100%) rename benchmarks/src/{main => test}/java/zipkin2/codec/CodecBenchmarks.java (100%) rename benchmarks/src/{main => test}/java/zipkin2/codec/JacksonSpanDecoder.java (100%) rename benchmarks/src/{main => test}/java/zipkin2/codec/JsonCodecBenchmarks.java (100%) rename benchmarks/src/{main => test}/java/zipkin2/codec/MoshiSpanDecoder.java (99%) rename benchmarks/src/{main => test}/java/zipkin2/codec/ProtoCodecBenchmarks.java (100%) rename benchmarks/src/{main => test}/java/zipkin2/codec/ProtobufSpanDecoder.java (100%) rename benchmarks/src/{main => test}/java/zipkin2/codec/WireSpanDecoder.java (99%) rename benchmarks/src/{main => test}/java/zipkin2/collector/MetricsBenchmarks.java (97%) rename benchmarks/src/{main => test}/java/zipkin2/elasticsearch/internal/BulkRequestBenchmarks.java (100%) rename benchmarks/src/{main => test}/java/zipkin2/internal/DelayLimiterBenchmarks.java (100%) rename benchmarks/src/{main => test}/java/zipkin2/internal/ReadBufferBenchmarks.java (100%) rename benchmarks/src/{main => test}/java/zipkin2/internal/WriteBufferBenchmarks.java (100%) rename benchmarks/src/{main => test}/java/zipkin2/server/internal/throttle/ThrottledCallBenchmarks.java (100%) delete mode 100644 benchmarks/src/test/resources/log4j2.properties create mode 100644 benchmarks/src/test/resources/simplelogger.properties rename benchmarks/src/{main => test}/resources/zipkin2-chinese.json (100%) rename benchmarks/src/{main => test}/resources/zipkin2-client.json (100%) diff --git a/benchmarks/README.md b/benchmarks/README.md index 7208f86ed4b..3e8399cc20b 100644 --- a/benchmarks/README.md +++ b/benchmarks/README.md @@ -1,14 +1,17 @@ -Zipkin Benchmarks -=================== +# zipkin-benchmarks -This module includes [JMH](http://openjdk.java.net/projects/code-tools/jmh/) benchmarks for Zipkin. +This module includes [JMH](http://openjdk.java.net/projects/code-tools/jmh/) +benchmarks for zipkin. You can use these to measure overhead. -=== Running the benchmark -From the parent directory, run `./mvnw install` to build the benchmarks, and the following to run them: +### Running the benchmark +From the project directory, run this to build the benchmarks: + +```bash +$ ./mvnw install -pl benchmarks -am -Dmaven.test.skip.exec=true +``` + +and the following to run them: ```bash -# Run with a single worker thread $ java -jar benchmarks/target/benchmarks.jar -# Add contention by running with 4 threads -$ java -jar benchmarks/target/benchmarks.jar -t4 ``` diff --git a/benchmarks/pom.xml b/benchmarks/pom.xml index 2f9007129d1..e2e26b52ad7 100644 --- a/benchmarks/pom.xml +++ b/benchmarks/pom.xml @@ -5,7 +5,9 @@ SPDX-License-Identifier: Apache-2.0 --> - + 4.0.0 @@ -50,12 +52,42 @@ + + + + com.squareup.wire + wire-runtime-jvm + ${wire.version} + provided + + + io.zipkin.proto3 + zipkin-proto3 + ${zipkin-proto3.version} + provided + + + + org.openjdk.jmh + jmh-core + ${jmh.version} + test + + + + org.openjdk.jmh + jmh-generator-annprocess + ${jmh.version} + test + com.google.code.gson gson ${gson.version} + test com.squareup.moshi @@ -68,52 +100,57 @@ okio + test com.esotericsoftware kryo ${kryo.version} - - - - org.openjdk.jmh - jmh-core - ${jmh.version} - - - - org.openjdk.jmh - jmh-generator-annprocess - ${jmh.version} - provided + test com.google.protobuf protobuf-java 3.25.3 + test + ${project.groupId} zipkin-server ${project.version} + + + org.slf4j + * + + + org.springframework.boot + spring-boot-starter-log4j2 + + + test - ${project.groupId}.zipkin2 - zipkin-storage-elasticsearch - ${project.version} + org.slf4j + slf4j-simple + ${slf4j.version} + test - com.squareup.wire - wire-runtime-jvm - ${wire.version} + org.slf4j + jul-to-slf4j + ${slf4j.version} + - io.zipkin.proto3 - zipkin-proto3 - ${zipkin-proto3.version} + ${project.groupId}.zipkin2 + zipkin-storage-elasticsearch + ${project.version} + test ${project.groupId}.zipkin2 @@ -133,6 +170,7 @@ * + test org.apache.cassandra @@ -211,31 +249,32 @@ + - maven-dependency-plugin - - - de.m3y.maven - wire-maven-plugin - - - - maven-shade-plugin + maven-assembly-plugin + ${maven-assembly-plugin.version} + + + src/test/assembly/test-jar.xml + + + make-assembly package - shade + single + true benchmarks - - + false + + org.openjdk.jmh.Main - - - false + + @@ -253,11 +292,41 @@ javac - + + + + + test-compile + test-compile + + testCompile + + + + javac + + + + + org.openjdk.jmh + jmh-generator-annprocess + ${jmh.version} + + + + maven-dependency-plugin + + + de.m3y.maven + wire-maven-plugin + + ${generated-proto.directory} + + diff --git a/benchmarks/src/test/assembly/test-jar.xml b/benchmarks/src/test/assembly/test-jar.xml new file mode 100644 index 00000000000..88c163ca2a5 --- /dev/null +++ b/benchmarks/src/test/assembly/test-jar.xml @@ -0,0 +1,35 @@ + + + + test-jar + + jar + + false + + + / + true + true + test + + + + + ${project.build.directory}/test-classes + / + + **/* + + true + + + diff --git a/benchmarks/src/main/java/zipkin2/EndpointBenchmarks.java b/benchmarks/src/test/java/zipkin2/EndpointBenchmarks.java similarity index 100% rename from benchmarks/src/main/java/zipkin2/EndpointBenchmarks.java rename to benchmarks/src/test/java/zipkin2/EndpointBenchmarks.java diff --git a/benchmarks/src/main/java/zipkin2/SpanBenchmarks.java b/benchmarks/src/test/java/zipkin2/SpanBenchmarks.java similarity index 100% rename from benchmarks/src/main/java/zipkin2/SpanBenchmarks.java rename to benchmarks/src/test/java/zipkin2/SpanBenchmarks.java diff --git a/benchmarks/src/main/java/zipkin2/codec/CodecBenchmarks.java b/benchmarks/src/test/java/zipkin2/codec/CodecBenchmarks.java similarity index 100% rename from benchmarks/src/main/java/zipkin2/codec/CodecBenchmarks.java rename to benchmarks/src/test/java/zipkin2/codec/CodecBenchmarks.java diff --git a/benchmarks/src/main/java/zipkin2/codec/JacksonSpanDecoder.java b/benchmarks/src/test/java/zipkin2/codec/JacksonSpanDecoder.java similarity index 100% rename from benchmarks/src/main/java/zipkin2/codec/JacksonSpanDecoder.java rename to benchmarks/src/test/java/zipkin2/codec/JacksonSpanDecoder.java diff --git a/benchmarks/src/main/java/zipkin2/codec/JsonCodecBenchmarks.java b/benchmarks/src/test/java/zipkin2/codec/JsonCodecBenchmarks.java similarity index 100% rename from benchmarks/src/main/java/zipkin2/codec/JsonCodecBenchmarks.java rename to benchmarks/src/test/java/zipkin2/codec/JsonCodecBenchmarks.java diff --git a/benchmarks/src/main/java/zipkin2/codec/MoshiSpanDecoder.java b/benchmarks/src/test/java/zipkin2/codec/MoshiSpanDecoder.java similarity index 99% rename from benchmarks/src/main/java/zipkin2/codec/MoshiSpanDecoder.java rename to benchmarks/src/test/java/zipkin2/codec/MoshiSpanDecoder.java index 8e6d671e896..4711fb616be 100644 --- a/benchmarks/src/main/java/zipkin2/codec/MoshiSpanDecoder.java +++ b/benchmarks/src/test/java/zipkin2/codec/MoshiSpanDecoder.java @@ -236,5 +236,4 @@ public void toJson(JsonWriter writer, @Nullable Endpoint value) { throw new UnsupportedOperationException(); } }.nullSafe(); - } diff --git a/benchmarks/src/main/java/zipkin2/codec/ProtoCodecBenchmarks.java b/benchmarks/src/test/java/zipkin2/codec/ProtoCodecBenchmarks.java similarity index 100% rename from benchmarks/src/main/java/zipkin2/codec/ProtoCodecBenchmarks.java rename to benchmarks/src/test/java/zipkin2/codec/ProtoCodecBenchmarks.java diff --git a/benchmarks/src/main/java/zipkin2/codec/ProtobufSpanDecoder.java b/benchmarks/src/test/java/zipkin2/codec/ProtobufSpanDecoder.java similarity index 100% rename from benchmarks/src/main/java/zipkin2/codec/ProtobufSpanDecoder.java rename to benchmarks/src/test/java/zipkin2/codec/ProtobufSpanDecoder.java diff --git a/benchmarks/src/main/java/zipkin2/codec/WireSpanDecoder.java b/benchmarks/src/test/java/zipkin2/codec/WireSpanDecoder.java similarity index 99% rename from benchmarks/src/main/java/zipkin2/codec/WireSpanDecoder.java rename to benchmarks/src/test/java/zipkin2/codec/WireSpanDecoder.java index 72752e5a538..6c923db0c40 100644 --- a/benchmarks/src/main/java/zipkin2/codec/WireSpanDecoder.java +++ b/benchmarks/src/test/java/zipkin2/codec/WireSpanDecoder.java @@ -284,7 +284,7 @@ private static String readHexString(ProtoReader input) throws IOException { char[] result = RecyclableBuffers.shortStringBuffer(); - for (int i = 0; i < bytes.size(); i ++) { + for (int i = 0; i < bytes.size(); i++) { byte b = bytes.getByte(i); result[2 * i] = HEX_DIGITS[(b >> 4) & 0xf]; result[2 * i + 1] = HEX_DIGITS[b & 0xf]; diff --git a/benchmarks/src/main/java/zipkin2/collector/MetricsBenchmarks.java b/benchmarks/src/test/java/zipkin2/collector/MetricsBenchmarks.java similarity index 97% rename from benchmarks/src/main/java/zipkin2/collector/MetricsBenchmarks.java rename to benchmarks/src/test/java/zipkin2/collector/MetricsBenchmarks.java index 141604105b3..b6a677f93d3 100644 --- a/benchmarks/src/main/java/zipkin2/collector/MetricsBenchmarks.java +++ b/benchmarks/src/test/java/zipkin2/collector/MetricsBenchmarks.java @@ -38,8 +38,9 @@ public class MetricsBenchmarks { private MeterRegistry registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT); private InMemoryCollectorMetrics inMemoryCollectorMetrics = new InMemoryCollectorMetrics() .forTransport("jmh"); - private MicrometerCollectorMetrics micrometerCollectorMetrics = new MicrometerCollectorMetrics(registry) - .forTransport("jmh"); + private MicrometerCollectorMetrics micrometerCollectorMetrics = + new MicrometerCollectorMetrics(registry) + .forTransport("jmh"); @Benchmark public int incrementBytes_longSpans_inMemory() { diff --git a/benchmarks/src/main/java/zipkin2/elasticsearch/internal/BulkRequestBenchmarks.java b/benchmarks/src/test/java/zipkin2/elasticsearch/internal/BulkRequestBenchmarks.java similarity index 100% rename from benchmarks/src/main/java/zipkin2/elasticsearch/internal/BulkRequestBenchmarks.java rename to benchmarks/src/test/java/zipkin2/elasticsearch/internal/BulkRequestBenchmarks.java diff --git a/benchmarks/src/main/java/zipkin2/internal/DelayLimiterBenchmarks.java b/benchmarks/src/test/java/zipkin2/internal/DelayLimiterBenchmarks.java similarity index 100% rename from benchmarks/src/main/java/zipkin2/internal/DelayLimiterBenchmarks.java rename to benchmarks/src/test/java/zipkin2/internal/DelayLimiterBenchmarks.java diff --git a/benchmarks/src/main/java/zipkin2/internal/ReadBufferBenchmarks.java b/benchmarks/src/test/java/zipkin2/internal/ReadBufferBenchmarks.java similarity index 100% rename from benchmarks/src/main/java/zipkin2/internal/ReadBufferBenchmarks.java rename to benchmarks/src/test/java/zipkin2/internal/ReadBufferBenchmarks.java diff --git a/benchmarks/src/main/java/zipkin2/internal/WriteBufferBenchmarks.java b/benchmarks/src/test/java/zipkin2/internal/WriteBufferBenchmarks.java similarity index 100% rename from benchmarks/src/main/java/zipkin2/internal/WriteBufferBenchmarks.java rename to benchmarks/src/test/java/zipkin2/internal/WriteBufferBenchmarks.java diff --git a/benchmarks/src/test/java/zipkin2/server/ServerIntegratedBenchmark.java b/benchmarks/src/test/java/zipkin2/server/ServerIntegratedBenchmark.java index 08c0a5896bb..36da9c103cc 100644 --- a/benchmarks/src/test/java/zipkin2/server/ServerIntegratedBenchmark.java +++ b/benchmarks/src/test/java/zipkin2/server/ServerIntegratedBenchmark.java @@ -225,9 +225,10 @@ void runBenchmark(@Nullable GenericContainer storage, GenericContainer zip printQuartiles(prometheusClient, "jvm_memory_used_bytes{area=\"nonheap\"}"); System.out.printf( - "Total GC time (s): %s%n", prometheusValue(prometheusClient, "sum(jvm_gc_pause_seconds_sum)")); + "Total GC time (s): %s%n", + prometheusValue(prometheusClient, "sum(jvm_gc_pause_seconds_sum)")); System.out.printf( - "Number of GCs: %s%n", prometheusValue(prometheusClient, "sum(jvm_gc_pause_seconds_count)")); + "Number of GCs: %s%n", prometheusValue(prometheusClient, "sum(jvm_gc_pause_seconds_count)")); System.out.println("POST Spans latency (s)"); printHistogram(prometheusClient, """ @@ -322,11 +323,11 @@ GenericContainer createZipkinContainer(@Nullable GenericContainer storage) static void printContainerMapping(GenericContainer container) { System.out.printf( - "Container %s ports exposed at %s%n", container.getDockerImageName(), - container.getExposedPorts().stream() - .map(port -> Map.entry(port, - "http://" + container.getContainerIpAddress() + ":" + container.getMappedPort(port))) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))); + "Container %s ports exposed at %s%n", container.getDockerImageName(), + container.getExposedPorts().stream() + .map(port -> Map.entry(port, + "http://" + container.getContainerIpAddress() + ":" + container.getMappedPort(port))) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))); } static void printQuartiles(WebClient prometheus, String metric) throws Exception { diff --git a/benchmarks/src/main/java/zipkin2/server/internal/throttle/ThrottledCallBenchmarks.java b/benchmarks/src/test/java/zipkin2/server/internal/throttle/ThrottledCallBenchmarks.java similarity index 100% rename from benchmarks/src/main/java/zipkin2/server/internal/throttle/ThrottledCallBenchmarks.java rename to benchmarks/src/test/java/zipkin2/server/internal/throttle/ThrottledCallBenchmarks.java diff --git a/benchmarks/src/test/resources/log4j2.properties b/benchmarks/src/test/resources/log4j2.properties deleted file mode 100644 index 9ad290ad826..00000000000 --- a/benchmarks/src/test/resources/log4j2.properties +++ /dev/null @@ -1,9 +0,0 @@ -status = error - -appender.console.type = Console -appender.console.name = console -appender.console.layout.type = PatternLayout -appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] [%node_name]%marker %m%n - -rootLogger.level = info -rootLogger.appenderRef.console.ref = console diff --git a/benchmarks/src/test/resources/simplelogger.properties b/benchmarks/src/test/resources/simplelogger.properties new file mode 100644 index 00000000000..2c440adb3b4 --- /dev/null +++ b/benchmarks/src/test/resources/simplelogger.properties @@ -0,0 +1,9 @@ +# See https://www.slf4j.org/api/org/slf4j/impl/SimpleLogger.html for the full list of config options + +org.slf4j.simpleLogger.logFile=System.out +org.slf4j.simpleLogger.defaultLogLevel=warn +org.slf4j.simpleLogger.showDateTime=true +org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS + +# uncomment to include kafka consumer configuration in test logs +#logger.org.apache.kafka.clients.level=info diff --git a/benchmarks/src/main/resources/zipkin2-chinese.json b/benchmarks/src/test/resources/zipkin2-chinese.json similarity index 100% rename from benchmarks/src/main/resources/zipkin2-chinese.json rename to benchmarks/src/test/resources/zipkin2-chinese.json diff --git a/benchmarks/src/main/resources/zipkin2-client.json b/benchmarks/src/test/resources/zipkin2-client.json similarity index 100% rename from benchmarks/src/main/resources/zipkin2-client.json rename to benchmarks/src/test/resources/zipkin2-client.json diff --git a/pom.xml b/pom.xml index 2e8dd110ea1..3292b022618 100755 --- a/pom.xml +++ b/pom.xml @@ -84,15 +84,17 @@ 4.12.0 5.6.0 - 4.9.7 + 4.9.9 2.10.1 ${project.build.directory}/test/proto ${skipTests} + 3.5.0 1.2.8 4.3 + 3.6.0 5.1.9 3.12.1 diff --git a/zipkin-server/pom.xml b/zipkin-server/pom.xml index 137cb2f8fe7..68cdd66c9e6 100644 --- a/zipkin-server/pom.xml +++ b/zipkin-server/pom.xml @@ -548,7 +548,7 @@ org.codehaus.mojo build-helper-maven-plugin - 3.5.0 + ${build-helper-maven-plugin.version} add-test-source