Skip to content

Commit

Permalink
Skip task scope creation for Graal VMOperation threads (avoids unexpe…
Browse files Browse the repository at this point in the history
…cted allocation issue when using G1-GC) (#6078)
  • Loading branch information
mcculls authored Oct 23, 2023
1 parent fcb4d04 commit 6f0485d
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
package datadog.trace.instrumentation.graal.nativeimage;

import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named;
import static datadog.trace.bootstrap.instrumentation.java.concurrent.ExcludeFilter.ExcludeType.RUNNABLE;
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;

import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.ExcludeFilterProvider;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.api.Config;
import datadog.trace.bootstrap.instrumentation.java.concurrent.ExcludeFilter;
import datadog.trace.logging.GlobalLogLevelSwitcher;
import datadog.trace.logging.LogLevel;
import java.util.Collection;
import java.util.Map;
import net.bytebuddy.asm.Advice;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@AutoService(Instrumenter.class)
public final class VMRuntimeInstrumentation extends AbstractNativeImageInstrumentation
implements Instrumenter.ForSingleType {
implements Instrumenter.ForSingleType, ExcludeFilterProvider {

@Override
public String instrumentedType() {
Expand All @@ -38,6 +45,12 @@ public boolean injectHelperDependencies() {
return true;
}

@Override
public Map<ExcludeFilter.ExcludeType, ? extends Collection<String>> excludedClasses() {
return singletonMap(
RUNNABLE, singletonList("com.oracle.svm.core.thread.VMOperationControl$VMOperationThread"));
}

public static class InitializeAdvice {
@Advice.OnMethodEnter(suppress = Throwable.class)
public static void onEnter() {
Expand Down

0 comments on commit 6f0485d

Please sign in to comment.