Draft
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace INVOKESTATIC handler copying with INVOKEDYNAMIC dispatch via ConstantCallSite for probe handler isolation - Transform AnyType→Object in probe method descriptors - Skip auxiliary frames in StackWalker classloader resolution - Add real instrumentation JMH benchmarks (DispatchBenchmark) - Fix ConcurrentHashMap.computeIfAbsent null NPE in handler cache - Add symmetric unregisterProbe on probe unregister - Remove premature registerProbe from BTraceProbeFactory - Unify static/dynamic/leveled golden files into single set - Delete CopyingVisitor and Indy (no longer needed) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace INVOKESTATIC handler copying with INVOKEDYNAMIC dispatch. Probe handler methods now stay in the probe class (bootstrap CL) and are called via
ConstantCallSite, eliminating bytecode copying into target classes.Architecture change
Indy.class(Java 15-specific, reflection)IndyDispatcher+HandlerRepositoryinterfaceDispatch chain
Integration test fixes
AnyType descriptor transformation — Probe methods using
@AnyTypegetLorg/openjdk/btrace/core/types/AnyType;→Ljava/lang/Object;in descriptors so INVOKEDYNAMIC call site types match. Applied in bothBTraceProbeNode.getBytecode()andBTraceProbePersisted.register().StackWalker auxiliary frame skipping —
getCallerClassLoader()andgetCallerClass()inBTraceRuntimeImpl_9and_11now skiporg.openjdk.btrace.runtime.auxiliary.*frames so probe handler frames are transparent to classloader resolution.HandlerRepositoryImpl cleanup — Removed fragile
asType()fallback; handler resolution is now a cleanfindStaticlookup with warn-on-failure.Review fixes
ConcurrentHashMapdisallows null values; replaced withget()+put()pattern so failed resolutions aren't cached and can retry.HandlerRepositoryImpl.unregisterProbe()to bothBTraceProbeNode.unregister()andBTraceProbePersisted.unregister(). Removed prematureregisterProbefromBTraceProbeFactory.createProbe()— registration now happens only inprobe.register()afterdefinedClassis set.BTraceProbePersisted.transformAnyTypeDescriptors()— only descriptors change (not control flow), so existing frames are preserved as-is.COMPUTE_FRAMESwas unnecessary and riskedClassNotFoundExceptionduring hierarchy resolution.Client.onExit()(now handled by probe lifecycle).Benchmark results
DispatchBenchmarkuses the realBTraceTransformerpipeline to instrument a target class with a compiled BTrace probe, then measures dispatch overhead.@Duration: ~19.7 ns overhead — dominated by twoSystem.nanoTime()calls (~11 ns each on macOS), not dispatchFiles
New:
IndyDispatcher,HandlerRepository,DispatchBenchmark,DispatchTarget,Workload,DispatchScriptDeleted:
CopyingVisitor,Indy, ~400 redundant golden files (static/dynamic/leveled → unified)Refactored:
HandlerRepositoryImpl,Instrumentor,Assembler,BTraceProbeNode,BTraceProbePersisted,BTraceRuntimeImpl_9/_11Test plan
./gradlew :btrace-instr:test— all instrumentor tests pass./gradlew :integration-tests:test -Pintegration— all 22 integration tests pass (including Docker)./gradlew :benchmarks:runtime-benchmarks:jmh -PjmhInclude='DispatchBenchmark'— benchmarks run and produce stable results🤖 Generated with Claude Code