Reorder java-concurrent matchers
Move the expensive matcher to last.
In theory this should help, but did not seem to make a significant difference in basic startup benchmarks.
MODIFY
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/AbstractExecutorInstrumentation.java
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/AbstractExecutorInstrumentation.java
@@ -102,12 +102,10 @@ public abstract class AbstractExecutorInstrumentation extends Instrumenter.Defau
@Override
public ElementMatcher<TypeDescription> typeMatcher() {
- final ElementMatcher.Junction<TypeDescription> matcher =
- not(isInterface()).and(safeHasInterface(named(Executor.class.getName())));
- if (TRACE_ALL_EXECUTORS) {
- return matcher;
- }
- return matcher.and(
+ ElementMatcher.Junction<TypeDescription> matcher = not(isInterface());
+ if (!TRACE_ALL_EXECUTORS) {
+ matcher =
+ matcher.and(
new ElementMatcher<TypeDescription>() {
@Override
public boolean matches(final TypeDescription target) {
@@ -130,6 +128,9 @@ public abstract class AbstractExecutorInstrumentation extends Instrumenter.Defau
}
});
}
+ return matcher.and(
+ safeHasInterface(named(Executor.class.getName()))); // Apply expensive matcher last.
+ }
@Override
public String[] helperClassNames() {

MODIFY
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/FutureInstrumentation.java
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/FutureInstrumentation.java
@@ -79,7 +79,6 @@ public final class FutureInstrumentation extends Instrumenter.Default {
@Override
public ElementMatcher<TypeDescription> typeMatcher() {
return not(isInterface())
- .and(safeHasInterface(named(Future.class.getName())))
.and(
new ElementMatcher<TypeDescription>() {
@Override
@@ -90,7 +89,8 @@ public final class FutureInstrumentation extends Instrumenter.Default {
}
return whitelisted;
}
- });
+ })
+ .and(safeHasInterface(named(Future.class.getName()))); // Apply expensive matcher last.
}
@Override

Reorder java-concurrent matchers

Move the expensive matcher to last.

In theory this should help, but did not seem to make a significant difference in basic startup benchmarks.