Remove unhelpful benchmarks (#4766)

* Remove unhelpful benchmarks

* Restore one more benchmark

* spotless
This commit is contained in:
Nikita Salnikov-Tarnovski 2021-12-02 17:17:39 +02:00 committed by GitHub
parent f2c2b755d2
commit a70682c390
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 180 additions and 630 deletions

View File

@ -1,68 +0,0 @@
import net.ltgt.gradle.errorprone.errorprone
plugins {
id("me.champeau.jmh")
id("com.github.johnrengelman.shadow")
id("otel.java-conventions")
id("otel.jmh-conventions")
}
val caffeine2Version: String by project
dependencies {
jmh(platform(project(":dependencyManagement")))
jmh("io.opentelemetry:opentelemetry-api")
jmh("net.bytebuddy:byte-buddy-agent")
jmh(project(":instrumentation-api"))
jmh(project(":javaagent-instrumentation-api"))
jmh(project(":javaagent-tooling"))
jmh(project(":javaagent-extension-api"))
jmh("com.github.ben-manes.caffeine:caffeine:2.9.2")
jmh("javax.servlet:javax.servlet-api:4.0.1")
jmh("com.google.http-client:google-http-client:1.19.0")
jmh("org.eclipse.jetty:jetty-server:9.4.1.v20170120")
jmh("org.eclipse.jetty:jetty-servlet:9.4.1.v20170120")
jmh("org.slf4j:slf4j-api")
// used to provide lots of classes for TypeMatchingBenchmark
jmh("org.springframework:spring-web:4.3.28.RELEASE")
}
jmh {
profilers.set(listOf("io.opentelemetry.benchmark.UsedMemoryProfiler", "gc"))
duplicateClassesStrategy.set(DuplicatesStrategy.EXCLUDE)
val jmhIncludeSingleClass: String? by project
if (jmhIncludeSingleClass != null) {
includes.set(listOf(jmhIncludeSingleClass))
}
}
tasks {
// without disabling errorprone, jmh task fails with
// Task :benchmark:jmhCompileGeneratedClasses FAILED
// error: plug-in not found: ErrorProne
withType<JavaCompile>().configureEach {
options.errorprone {
isEnabled.set(false)
}
}
named("jmh") {
dependsOn(":javaagent:shadowJar")
}
}
/*
If using libasyncProfiler, use the following to generate nice svg flamegraphs.
sed '/unknown/d' benchmark/build/reports/jmh/profiler.txt | sed '/^thread_start/d' | sed '/not_walkable/d' > benchmark/build/reports/jmh/profiler-cleaned.txt
(using https://github.com/brendangregg/FlameGraph)
./flamegraph.pl --color=java benchmark/build/reports/jmh/profiler-cleaned.txt > benchmark/build/reports/jmh/jmh-main.svg
*/

View File

@ -1,40 +0,0 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.benchmark;
import io.opentelemetry.benchmark.classes.TracedClass;
import io.opentelemetry.benchmark.classes.UntracedClass;
import java.lang.instrument.Instrumentation;
import java.lang.instrument.UnmodifiableClassException;
import net.bytebuddy.agent.ByteBuddyAgent;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
public class ClassRetransformingBenchmark {
@State(Scope.Benchmark)
public static class BenchmarkState {
private final Instrumentation inst = ByteBuddyAgent.install();
}
@Benchmark
public void testUntracedRetransform(BenchmarkState state) throws UnmodifiableClassException {
state.inst.retransformClasses(UntracedClass.class);
}
@Benchmark
public void testTracedRetransform(BenchmarkState state) throws UnmodifiableClassException {
state.inst.retransformClasses(TracedClass.class);
}
@Fork(
jvmArgsAppend =
"-javaagent:/path/to/opentelemetry-java-instrumentation"
+ "/javaagent/build/libs/opentelemetry-javaagent.jar")
public static class WithAgent extends ClassRetransformingBenchmark {}
}

View File

@ -1,71 +0,0 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.benchmark;
import io.opentelemetry.benchmark.classes.HttpClass;
import java.io.IOException;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class HttpBenchmark {
private static final Logger logger = LoggerFactory.getLogger(HttpBenchmark.class);
@State(Scope.Benchmark)
public static class BenchmarkState {
@Setup(Level.Trial)
public void doSetup() {
try {
jettyServer = new HttpClass().buildJettyServer();
jettyServer.start();
// Make sure it's actually running
while (!AbstractLifeCycle.STARTED.equals(jettyServer.getState())) {
Thread.sleep(500);
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IllegalStateException(e);
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
@TearDown(Level.Trial)
public void doTearDown() {
try {
jettyServer.stop();
} catch (Exception e) {
logger.warn("Error", e);
} finally {
jettyServer.destroy();
}
}
HttpClass http = new HttpClass();
Server jettyServer;
}
@Benchmark
public void testMakingRequest(BenchmarkState state) throws IOException {
state.http.executeRequest();
}
@Fork(
jvmArgsAppend = {
"-javaagent:/path/to/opentelemetry-java-instrumentation/java-agent/build/libs/opentelemetry-javaagent.jar",
"-Dotel.traces.exporter=logging"
})
public static class WithAgent extends ClassRetransformingBenchmark {}
}

View File

@ -1,74 +0,0 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.benchmark;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import java.io.File;
import java.io.IOException;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Set;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Warmup;
@BenchmarkMode(Mode.SingleShotTime)
@Fork(5)
@Warmup(iterations = 0)
@Measurement(iterations = 1)
@OutputTimeUnit(MILLISECONDS)
public class TypeMatchingBenchmark {
private static final Set<String> classNames;
static {
classNames = new HashSet<>();
String classPath = System.getProperty("java.class.path");
for (String path : classPath.split(File.pathSeparator)) {
if (!path.endsWith(".jar")) {
continue;
}
try (JarFile jarFile = new JarFile(path)) {
Enumeration<JarEntry> e = jarFile.entries();
while (e.hasMoreElements()) {
JarEntry jarEntry = e.nextElement();
String name = jarEntry.getName();
if (name.endsWith(".class")) {
name = name.replace('/', '.');
name = name.substring(0, name.length() - ".class".length());
classNames.add(name);
}
}
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
}
@Benchmark
public void loadLotsOfClasses() throws ClassNotFoundException {
for (String className : classNames) {
try {
Class.forName(className, false, TypeMatchingBenchmark.class.getClassLoader());
} catch (NoClassDefFoundError e) {
// many classes in the jar files have optional dependencies which are not present
}
}
}
@Fork(
jvmArgsAppend =
"-javaagent:/path/to/opentelemetry-java-instrumentation"
+ "/javaagent/build/libs/opentelemetry-javaagent.jar")
public static class WithAgent extends TypeMatchingBenchmark {}
}

View File

@ -1,53 +0,0 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.benchmark;
import java.util.ArrayList;
import java.util.Collection;
import org.openjdk.jmh.infra.BenchmarkParams;
import org.openjdk.jmh.infra.IterationParams;
import org.openjdk.jmh.profile.InternalProfiler;
import org.openjdk.jmh.results.AggregationPolicy;
import org.openjdk.jmh.results.IterationResult;
import org.openjdk.jmh.results.Result;
import org.openjdk.jmh.results.ScalarResult;
public class UsedMemoryProfiler implements InternalProfiler {
private long totalHeapBefore;
private long usedHeapBefore;
@Override
public String getDescription() {
return "Used memory heap profiler";
}
@Override
public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams) {
System.gc();
System.runFinalization();
totalHeapBefore = Runtime.getRuntime().totalMemory();
usedHeapBefore = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
}
@Override
public Collection<? extends Result> afterIteration(
BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) {
long totalHeap = Runtime.getRuntime().totalMemory();
long usedHeap = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
Collection<ScalarResult> results = new ArrayList<>();
results.add(
new ScalarResult("heap.total.before", totalHeapBefore, "bytes", AggregationPolicy.AVG));
results.add(
new ScalarResult("heap.used.before", usedHeapBefore, "bytes", AggregationPolicy.AVG));
results.add(new ScalarResult("heap.total.after", totalHeap, "bytes", AggregationPolicy.AVG));
results.add(new ScalarResult("heap.used.after", usedHeap, "bytes", AggregationPolicy.AVG));
return results;
}
}

View File

@ -1,119 +0,0 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.benchmark;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import io.opentelemetry.context.internal.shaded.WeakConcurrentMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
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;
import org.openjdk.jmh.infra.Blackhole;
@Fork(3)
@Warmup(iterations = 10, time = 1)
@Measurement(iterations = 5, time = 1)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@State(Scope.Thread)
public class WeakMapBenchmark {
private static final WeakConcurrentMap<String, String> weakConcurrentMap =
new WeakConcurrentMap<>(true, true);
private static final WeakConcurrentMap<String, String> weakConcurrentMapInline =
new WeakConcurrentMap.WithInlinedExpunction<>();
private static final Cache<String, String> caffeineCache =
Caffeine.newBuilder().weakKeys().build();
private static final Map<String, String> caffeineMap = caffeineCache.asMap();
private String key;
@Setup
public void setUp() {
key = new String(Thread.currentThread().getName());
}
@Benchmark
@Threads(1)
public void threads01_weakConcurrentMap(Blackhole blackhole) {
blackhole.consume(weakConcurrentMap.put(key, "foo"));
blackhole.consume(weakConcurrentMap.get(key));
blackhole.consume(weakConcurrentMap.remove(key));
}
@Benchmark
@Threads(5)
public void threads05_weakConcurrentMap(Blackhole blackhole) {
blackhole.consume(weakConcurrentMap.put(key, "foo"));
blackhole.consume(weakConcurrentMap.get(key));
blackhole.consume(weakConcurrentMap.remove(key));
}
@Benchmark
@Threads(10)
public void threads10_weakConcurrentMap(Blackhole blackhole) {
blackhole.consume(weakConcurrentMap.put(key, "foo"));
blackhole.consume(weakConcurrentMap.get(key));
blackhole.consume(weakConcurrentMap.remove(key));
}
@Benchmark
@Threads(1)
public void threads01_weakConcurrentMap_inline(Blackhole blackhole) {
blackhole.consume(weakConcurrentMapInline.put(key, "foo"));
blackhole.consume(weakConcurrentMapInline.get(key));
blackhole.consume(weakConcurrentMapInline.remove(key));
}
@Benchmark
@Threads(5)
public void threads05_weakConcurrentMap_inline(Blackhole blackhole) {
blackhole.consume(weakConcurrentMapInline.put(key, "foo"));
blackhole.consume(weakConcurrentMapInline.get(key));
blackhole.consume(weakConcurrentMapInline.remove(key));
}
@Benchmark
@Threads(10)
public void threads10_weakConcurrentMap_inline(Blackhole blackhole) {
blackhole.consume(weakConcurrentMapInline.put(key, "foo"));
blackhole.consume(weakConcurrentMapInline.get(key));
blackhole.consume(weakConcurrentMapInline.remove(key));
}
@Benchmark
@Threads(1)
public void threads01_caffeine(Blackhole blackhole) {
blackhole.consume(caffeineMap.put(key, "foo"));
blackhole.consume(caffeineMap.get(key));
blackhole.consume(caffeineMap.remove(key));
}
@Benchmark
@Threads(5)
public void threads05_caffeine(Blackhole blackhole) {
blackhole.consume(caffeineMap.put(key, "foo"));
blackhole.consume(caffeineMap.get(key));
blackhole.consume(caffeineMap.remove(key));
}
@Benchmark
@Threads(10)
public void threads10_caffeine(Blackhole blackhole) {
blackhole.consume(caffeineMap.put(key, "foo"));
blackhole.consume(caffeineMap.get(key));
blackhole.consume(caffeineMap.remove(key));
}
}

View File

@ -1,11 +0,0 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.benchmark.classes;
@SuppressWarnings("ClassNamedLikeTypeParameter")
public interface A {
void a();
}

View File

@ -1,11 +0,0 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.benchmark.classes;
@SuppressWarnings("ClassNamedLikeTypeParameter")
public interface B extends A {
void b();
}

View File

@ -1,11 +0,0 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.benchmark.classes;
@SuppressWarnings("ClassNamedLikeTypeParameter")
public interface C extends A, B {
void c();
}

View File

@ -1,11 +0,0 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.benchmark.classes;
@SuppressWarnings("ClassNamedLikeTypeParameter")
public interface D extends A, B, C {
void d();
}

View File

@ -1,11 +0,0 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.benchmark.classes;
@SuppressWarnings("ClassNamedLikeTypeParameter")
public interface E extends B, C, D {
void e();
}

View File

@ -1,13 +0,0 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.benchmark.classes;
@SuppressWarnings("ClassNamedLikeTypeParameter")
public abstract class F implements E {
public abstract void f();
public void g() {}
}

View File

@ -1,61 +0,0 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.benchmark.classes;
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestFactory;
import com.google.api.client.http.javanet.NetHttpTransport;
import java.io.IOException;
import java.net.InetSocketAddress;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
public class HttpClass {
private static final String contextPath = "/path";
private static final Integer port = 18888;
public Server buildJettyServer() {
System.setProperty("org.eclipse.jetty.util.log.class", "org.eclipse.jetty.util.log.StdErrLog");
System.setProperty("org.eclipse.jetty.LEVEL", "WARN");
Server jettyServer = new Server(new InetSocketAddress("localhost", port));
ServletContextHandler servletContext = new ServletContextHandler();
servletContext.addServlet(HttpClassServlet.class, contextPath);
jettyServer.setHandler(servletContext);
return jettyServer;
}
@WebServlet
public static class HttpClassServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
resp.setContentType("application/json");
resp.setStatus(HttpServletResponse.SC_OK);
resp.getWriter().println("{ \"status\": \"ok\"}");
}
}
private final HttpRequestFactory requestFactory = new NetHttpTransport().createRequestFactory();
public void executeRequest() throws IOException {
String url = "http://localhost:" + port + contextPath;
HttpRequest request = requestFactory.buildGetRequest(new GenericUrl(url));
request.setThrowExceptionOnExecuteError(false);
request.execute();
}
}

View File

@ -1,43 +0,0 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.benchmark.classes;
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.trace.Tracer;
public class TracedClass extends UntracedClass {
private static final Tracer tracer = GlobalOpenTelemetry.getTracer("test");
@Override
public void f() {
tracer.spanBuilder("f").startSpan().end();
}
@Override
public void e() {
tracer.spanBuilder("e").startSpan().end();
}
@Override
public void d() {
tracer.spanBuilder("d").startSpan().end();
}
@Override
public void c() {
tracer.spanBuilder("c").startSpan().end();
}
@Override
public void b() {
tracer.spanBuilder("b").startSpan().end();
}
@Override
public void a() {
tracer.spanBuilder("a").startSpan().end();
}
}

View File

@ -1,26 +0,0 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.benchmark.classes;
public class UntracedClass extends F {
@Override
public void f() {}
@Override
public void e() {}
@Override
public void d() {}
@Override
public void c() {}
@Override
public void b() {}
@Override
public void a() {}
}

View File

@ -1,3 +1,5 @@
import net.ltgt.gradle.errorprone.errorprone
plugins {
id("org.xbib.gradle.plugin.jflex")
@ -6,6 +8,7 @@ plugins {
id("otel.jacoco-conventions")
id("otel.japicmp-conventions")
id("otel.publish-conventions")
id("otel.jmh-conventions")
}
sourceSets {
@ -65,4 +68,11 @@ tasks {
isFailOnNoMatchingTests = false
}
}
// TODO this should live in jmh-conventions
named<JavaCompile>("jmhCompileGeneratedClasses") {
options.errorprone {
isEnabled.set(false)
}
}
}

View File

@ -0,0 +1,158 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.instrumentation.api.cache.internal;
import io.opentelemetry.instrumentation.api.cache.Cache;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
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;
import org.openjdk.jmh.infra.Blackhole;
@Fork(3)
@Warmup(iterations = 10, time = 1)
@Measurement(iterations = 5, time = 1)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@State(Scope.Thread)
public class CacheBenchmark {
private static final Cache<Object, Object> weakCache = Cache.weak();
private static final Cache<Object, Object> boundedLargeCache = Cache.bounded(10);
private static final Cache<Object, Object> boundedSmallCache = Cache.bounded(1);
private String key;
private String key2;
@SuppressWarnings("StringOperationCanBeSimplified")
@Setup
public void setUp() {
key = new String(Thread.currentThread().getName());
key2 = new String(Thread.currentThread().getName()) + "2";
}
@Benchmark
@Threads(1)
public void threads01_weakConcurrentMap(Blackhole blackhole) {
weakCache.put(key, "foo");
blackhole.consume(weakCache.get(key));
weakCache.put(key2, "foo");
blackhole.consume(weakCache.get(key2));
weakCache.remove(key);
weakCache.remove(key2);
blackhole.consume(weakCache.get(key));
blackhole.consume(weakCache.get(key2));
}
@Benchmark
@Threads(5)
public void threads05_weakConcurrentMap(Blackhole blackhole) {
weakCache.put(key, "foo");
blackhole.consume(weakCache.get(key));
weakCache.put(key2, "foo");
blackhole.consume(weakCache.get(key2));
weakCache.remove(key);
weakCache.remove(key2);
blackhole.consume(weakCache.get(key));
blackhole.consume(weakCache.get(key2));
}
@Benchmark
@Threads(10)
public void threads10_weakConcurrentMap(Blackhole blackhole) {
weakCache.put(key, "foo");
blackhole.consume(weakCache.get(key));
weakCache.put(key2, "foo");
blackhole.consume(weakCache.get(key2));
weakCache.remove(key);
weakCache.remove(key2);
blackhole.consume(weakCache.get(key));
blackhole.consume(weakCache.get(key2));
}
@Benchmark
@Threads(1)
public void threads01_boundedLarge(Blackhole blackhole) {
boundedLargeCache.put(key, "foo");
blackhole.consume(boundedLargeCache.get(key));
boundedLargeCache.put(key2, "foo");
blackhole.consume(boundedLargeCache.get(key2));
boundedLargeCache.remove(key);
boundedLargeCache.remove(key2);
blackhole.consume(boundedLargeCache.get(key));
blackhole.consume(boundedLargeCache.get(key2));
}
@Benchmark
@Threads(5)
public void threads05_boundedLarge(Blackhole blackhole) {
boundedLargeCache.put(key, "foo");
blackhole.consume(boundedLargeCache.get(key));
boundedLargeCache.put(key2, "foo");
blackhole.consume(boundedLargeCache.get(key2));
boundedLargeCache.remove(key);
boundedLargeCache.remove(key2);
blackhole.consume(boundedLargeCache.get(key));
blackhole.consume(boundedLargeCache.get(key2));
}
@Benchmark
@Threads(10)
public void threads10_boundedLarge(Blackhole blackhole) {
boundedLargeCache.put(key, "foo");
blackhole.consume(boundedLargeCache.get(key));
boundedLargeCache.put(key2, "foo");
blackhole.consume(boundedLargeCache.get(key2));
boundedLargeCache.remove(key);
boundedLargeCache.remove(key2);
blackhole.consume(boundedLargeCache.get(key));
blackhole.consume(boundedLargeCache.get(key2));
}
@Benchmark
@Threads(1)
public void threads01_boundedSmall(Blackhole blackhole) {
boundedSmallCache.put(key, "foo");
blackhole.consume(boundedSmallCache.get(key));
boundedSmallCache.put(key2, "foo");
blackhole.consume(boundedSmallCache.get(key2));
boundedSmallCache.remove(key);
boundedSmallCache.remove(key2);
blackhole.consume(boundedSmallCache.get(key));
blackhole.consume(boundedSmallCache.get(key2));
}
@Benchmark
@Threads(5)
public void threads05_boundedSmall(Blackhole blackhole) {
boundedSmallCache.put(key, "foo");
blackhole.consume(boundedSmallCache.get(key));
boundedSmallCache.put(key2, "foo");
blackhole.consume(boundedSmallCache.get(key2));
boundedSmallCache.remove(key);
boundedSmallCache.remove(key2);
blackhole.consume(boundedSmallCache.get(key));
blackhole.consume(boundedSmallCache.get(key2));
}
@Benchmark
@Threads(10)
public void threads10_boundedSmall(Blackhole blackhole) {
boundedSmallCache.put(key, "foo");
blackhole.consume(boundedSmallCache.get(key));
boundedSmallCache.put(key2, "foo");
blackhole.consume(boundedSmallCache.get(key2));
boundedSmallCache.remove(key);
boundedSmallCache.remove(key2);
blackhole.consume(boundedSmallCache.get(key));
blackhole.consume(boundedSmallCache.get(key2));
}
}

View File

@ -3,11 +3,10 @@
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.benchmark;
package io.opentelemetry.instrumentation.api.instrumenter;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.instrumentation.api.instrumenter.http.CapturedHttpHeaders;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;

View File

@ -1,6 +1,9 @@
import net.ltgt.gradle.errorprone.errorprone
plugins {
id("otel.java-conventions")
id("otel.publish-conventions")
id("otel.jmh-conventions")
}
group = "io.opentelemetry.javaagent"
@ -49,4 +52,11 @@ tasks {
environment("OTEL_TRACES_EXPORTER", "none")
environment("OTEL_METRICS_EXPORTER", "none")
}
// TODO this should live in jmh-conventions
named<JavaCompile>("jmhCompileGeneratedClasses") {
options.errorprone {
isEnabled.set(false)
}
}
}

View File

@ -3,12 +3,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.benchmark;
package io.opentelemetry.javaagent.tooling.ignore;
import io.opentelemetry.instrumentation.api.config.Config;
import io.opentelemetry.javaagent.tooling.ignore.AdditionalLibraryIgnoredTypesConfigurer;
import io.opentelemetry.javaagent.tooling.ignore.IgnoredTypesBuilderImpl;
import io.opentelemetry.javaagent.tooling.ignore.IgnoredTypesMatcher;
import java.util.concurrent.TimeUnit;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;

View File

@ -387,7 +387,6 @@ include(":instrumentation:vertx-web-3.0:testing")
include(":instrumentation:wicket-8.0:javaagent")
// benchmark
include(":benchmark")
include(":benchmark-e2e")
include(":benchmark-overhead-jmh")
include(":benchmark-jfr-analyzer")