Skip to content

Commit

Permalink
benchmarks: moves dependency scope to test (#262)
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Cole <adrian@tetrate.io>
  • Loading branch information
codefromthecrypt authored Apr 12, 2024
1 parent 939b6e4 commit 0c62f8b
Show file tree
Hide file tree
Showing 17 changed files with 107 additions and 82 deletions.
17 changes: 10 additions & 7 deletions benchmarks/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
Zipkin Reporter Benchmarks
===================
# zipkin-reporter-benchmarks

This module includes [JMH](http://openjdk.java.net/projects/code-tools/jmh/) benchmarks for Zipkin Reporter.
This module includes [JMH](http://openjdk.java.net/projects/code-tools/jmh/)
benchmarks for zipkin-reporter. 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:
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
```
130 changes: 61 additions & 69 deletions benchmarks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
SPDX-License-Identifier: Apache-2.0
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand All @@ -23,47 +25,64 @@
<jmh.version>1.37</jmh.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>zipkin-reporter-bom</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<!-- All dependencies are marked test, because benchmarks are a form of test.
This module is skipped on -DskipTests, ensuring it isn't deployed. -->
<dependencies>
<!-- can't import zipkin-reporter-bom due to build-support/go-offline.sh -->
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>${jmh.version}</version>
<scope>test</scope>
</dependency>
<!-- IntelliJ doesn't know to use annotation processing on tests without this -->
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>zipkin-reporter</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>zipkin-sender-urlconnection</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>zipkin-sender-okhttp3</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>zipkin-sender-kafka</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>zipkin-sender-amqp-client</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>zipkin-reporter-brave</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.zipkin.brave</groupId>
Expand All @@ -75,86 +94,52 @@
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>io.zipkin.zipkin2</groupId>
<artifactId>zipkin-tests</artifactId>
<version>${zipkin.version}</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>${jmh.version}</version>
</dependency>

<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh.version}</version>
<scope>provided</scope>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.linecorp.armeria</groupId>
<artifactId>armeria</artifactId>
<!-- match Zipkin version to avoid classpath problems -->
<version>1.26.4</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${testcontainers.version}</version>
</dependency>

<!-- Main code uses jul and tests log with log4j -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
<!-- route jul over log4j2 during integration tests -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jul</artifactId>
<version>${log4j.version}</version>
</dependency>
<!-- route log4j over log4j2 during integration tests -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<!-- route slf4j over log4j2 during integration tests -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<!-- use assembly instead of shade, as it naturally works for test-jar -->
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin.version}</version>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven-assembly-plugin.version}</version>
<configuration>
<descriptors>
<descriptor>src/test/assembly/test-jar.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
<goal>single</goal>
</goals>
<configuration>
<attach>true</attach>
<finalName>benchmarks</finalName>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<appendAssemblyId>false</appendAssemblyId>
<archive>
<manifest>
<mainClass>org.openjdk.jmh.Main</mainClass>
</transformer>
</transformers>
<createDependencyReducedPom>false</createDependencyReducedPom>
</manifest>
</archive>
</configuration>
</execution>
</executions>
Expand All @@ -164,15 +149,22 @@
<executions>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<phase>test-compile</phase>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
<configuration combine.self="override">
<!-- instead of javac-with-errorprone -->
<compilerId>javac</compilerId>
<!-- scrub errorprone compiler args -->
<compilerArgs />
<compilerArgs/>
<annotationProcessorPaths>
<path>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</execution>
</executions>
Expand Down
35 changes: 35 additions & 0 deletions benchmarks/src/test/assembly/test-jar.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!--
Copyright The OpenZipkin Authors
SPDX-License-Identifier: Apache-2.0
-->
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.2.0 https://maven.apache.org/xsd/assembly-2.2.0.xsd">
<!-- This is an alternative to maven-shade-plugin, which makes an executable
jar from the test source tree. This was made due to lack of success
getting 'shadeTestJar' and similar configuration working. -->
<id>test-jar</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<useProjectArtifact>true</useProjectArtifact>
<unpack>true</unpack>
<scope>test</scope>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>${project.build.directory}/test-classes</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>**/*</include>
</includes>
<useDefaultExcludes>true</useDefaultExcludes>
</fileSet>
</fileSets>
</assembly>
7 changes: 1 addition & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<go-offline-maven-plugin.version>1.2.8</go-offline-maven-plugin.version>
<!-- TODO: cleanup any redundant ignores now also in the 4.0 release (once final) -->
<license-maven-plugin.version>4.3</license-maven-plugin.version>
<maven-assembly-plugin.version>3.6.0</maven-assembly-plugin.version>
<maven-bundle-plugin.version>5.1.9</maven-bundle-plugin.version>
<maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
<!-- Use same version as https://github.com/openzipkin/docker-java -->
Expand All @@ -85,7 +86,6 @@
<maven-javadoc-plugin.version>3.6.3</maven-javadoc-plugin.version>
<maven-jar-plugin.version>3.3.0</maven-jar-plugin.version>
<maven-release-plugin.version>3.0.1</maven-release-plugin.version>
<maven-shade-plugin.version>3.5.2</maven-shade-plugin.version>
<maven-source-plugin.version>3.3.1</maven-source-plugin.version>
<maven-surefire-plugin.version>3.2.5</maven-surefire-plugin.version>
<nexus-staging-maven-plugin.version>1.6.13</nexus-staging-maven-plugin.version>
Expand Down Expand Up @@ -324,11 +324,6 @@
</configuration>
</plugin>

<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin.version}</version>
</plugin>

<plugin>
<artifactId>maven-invoker-plugin</artifactId>
<version>${maven-invoker-plugin.version}</version>
Expand Down

0 comments on commit 0c62f8b

Please sign in to comment.