Skip to content

Match outline members with compiled member patterns - #13746

Draft
dougqh wants to merge 1 commit into
dougqh/memoizer-member-prefilterfrom
dougqh/compiled-member-matchers
Draft

dougqh wants to merge 1 commit into
dougqh/memoizer-member-prefilterfrom
dougqh/compiled-member-matchers

Conversation

@dougqh

@dougqh dougqh commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

Stacked on #13744. Replaces the generic ElementMatcher predicate chains used for memoized member matching with one compiled matcher class, and has the memoizer route each member only to the matchers that could match it.

MemberPattern (a single final class) matches fields and methods by:

  • Name: exact, a set via methodNamed(...), or a single * at the start or end ("block*", "*Async"). Method names are internal names ("<init>" for constructors).
  • Descriptor pattern: ? stands for one whole parameter (or the return type), and a trailing * for any remaining parameters. "(??)?" takes exactly two parameters; "(Ljava/lang/String;*)V" takes a String first and returns void. Field descriptors are exact.
  • Access flags: mask and value, e.g. notStatic().
  • Annotations: the member must declare one of them. methodAnnotatedWith(...) registers them as annotations of interest, like isAnnotatedWith.

Cheap checks come first: flags, then a name-length bitmask and name buckets, then the descriptor's minimum length, then the descriptor, and annotations last.

MemberIndex (in the memoizer) indexes patterns by what their names require: exact names in a map behind a combined length mask, prefixes and suffixes in short lists, and nameless patterns by whether they need annotations. Each member is routed to the few patterns its name could satisfy, which are called directly on the final class (monomorphic). Any other matcher is residual and still sees every member. Routing only selects candidates; each selected pattern still decides.

Migration: every memoized member matcher in the instrumentations moves to MemberPattern, except the two declaredBy(...) matchers (JAX-WS / Jakarta WS) and code origin (off by default), which stay on the residual path. For example, jacoco's

named("visitMethodInsn").and(takesArguments(5)).and(takesArgument(0, int.class))
    .and(takesArgument(1, String.class)).and(takesArgument(2, String.class))
    .and(takesArgument(3, String.class)).and(takesArgument(4, boolean.class))

becomes method("visitMethodInsn", "(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)?").

Motivation

Profiling memo builds showed the cost was not any one slow matcher but volume: every declared member of every memoized type went through all ~21 method matchers (or 13 field matchers), about 1.6 million generic matcher calls per PetClinic startup, of which only a few dozen match.

Results

Behavior: PetClinic transforms the identical set of 114 classes as master (startup plus traffic), with no transformation failures.

Memoizer timings (triage metrics, PetClinic startup, 4 interleaved runs per build):

master #13744 this PR
Build type-memo 161.2 ms (159–169) 169.6 ms 118.3 ms (112–120), -27%
Type-hierarchy misses 199.3 ms 209.2 ms 160.6 ms, -19%
Matching, total 342.8 ms 360.4 ms 312.7 ms, -9%
Startup 4.457 s 4.728 s 4.548 s (within noise)

Tests:

  • New MemberPatternTest (25 cases): descriptor-pattern grammar and edge cases, and equivalence with the replaced ByteBuddy predicates (exact names, sets, prefixes and suffixes, parameter counts, typed and array parameters, return types, flags, field descriptors, annotations) over every member of a corpus of real classes.
  • New MemberIndexTest: routing records exactly the same matches as evaluating every matcher, for every member of the corpus, including residual matchers.
  • Instrumentation tests for migrated modules pass: trace-annotation (23), jax-rs-annotations-2.0 (83), reactor-core-3.1 (51), reactive-streams-1.0 (11), jackson-core-2.12 (4), java-concurrent-1.8 (467).

What's left after this

  • The two declaredBy matchers are per-type facts still evaluated per member; evaluating them once per type is the next small step.
  • Outlines still decode names to Strings in ClassFile.outline; the same pattern checks can run on class-file bytes, starting with the u2 length before any compare.
  • Per-instrumentation type-matcher dispatch (~200 ms, ~814,000 calls) is a separate cost, addressed by constant-pool needle tables.

Additional Notes

Formatting applied with spotlessApply. Two modules were skipped by the local build because they need private repositories (restlet-2.2, akka-http-10.6); neither is touched.

🤖 Generated with Claude Code

MemberPattern is a single final matcher class for fields and methods:
exact names, name sets, a leading or trailing '*', descriptor patterns where
'?' stands for one whole parameter and a trailing '*' for the rest, access
flags, and declared annotations. Length masks and minimum lengths reject
most members before any string comparison.

The memoizer indexes registered patterns by what their names require and
routes each member only to the patterns it could satisfy, calling the final
class directly; other matchers still see every member. Member matchers in
the instrumentations are migrated to patterns, except declaredBy matchers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dougqh dougqh added comp: core Tracer core tag: performance Performance related changes tag: no release notes Changes to exclude from release notes type: refactoring tag: ai generated Largely based on code generated by an AI or LLM labels Dec 1, 2026
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
• Patch Coverage: 0.00%
• Overall Coverage: 63.25% (-0.27%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 0545b31 | Docs | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 14.01 s 14.03 s [-0.9%; +0.6%] (no difference)
startup:insecure-bank:tracing:Agent 12.90 s 12.97 s [-1.2%; +0.2%] (no difference)
startup:petclinic:appsec:Agent 17.19 s 17.23 s [-0.9%; +0.4%] (no difference)
startup:petclinic:iast:Agent 16.98 s 17.26 s [-2.5%; -0.8%] (maybe better)
startup:petclinic:profiling:Agent 16.69 s 17.02 s [-2.9%; -0.9%] (maybe better)
startup:petclinic:sca:Agent 17.13 s 17.22 s [-1.5%; +0.4%] (no difference)
startup:petclinic:tracing:Agent 16.15 s 16.21 s [-1.5%; +0.7%] (no difference)

Commit: 0545b31a · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@pr-commenter

pr-commenter Bot commented Dec 1, 2026

Copy link
Copy Markdown

Kafka / producer-benchmark

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch dougqh/memoizer-member-prefilter dougqh/compiled-member-matchers
git_commit_date 1796093338 1796094970
git_commit_sha 3ed590e 0545b31
See matching parameters
Baseline Candidate
ci_job_date 1796096033 1796096033
ci_job_id 2313372898 2313372898
ci_pipeline_id 157101247 157101247
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
jdkVersion 11.0.31 11.0.31
jmhVersion 1.36 1.36
jvm /usr/lib/jvm/java-11-openjdk-amd64/bin/java /usr/lib/jvm/java-11-openjdk-amd64/bin/java
jvmArgs -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=15002 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=15002 -Dhttp.nonProxyHosts=localhost *.localhost
kernel_version Linux runner-zfyrx7zua-project-304-concurrent-0-oie3bcka 6.8.0-1031-aws #33~22.04.1-Ubuntu SMP Thu Jun 26 14:22:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux Linux runner-zfyrx7zua-project-304-concurrent-0-oie3bcka 6.8.0-1031-aws #33~22.04.1-Ubuntu SMP Thu Jun 26 14:22:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
vmName OpenJDK 64-Bit Server VM OpenJDK 64-Bit Server VM
vmVersion 11.0.31+11-post-1ubuntu1-22.04.2-Ubuntu 11.0.31+11-post-1ubuntu1-22.04.2-Ubuntu

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 3 metrics, 0 unstable metrics.

See unchanged results
scenario Δ mean throughput
scenario:not-instrumented/KafkaProduceBenchmark.benchProduce same
scenario:only-tracing-dsm-disabled-benchmarks/KafkaProduceBenchmark.benchProduce unsure
[-9582.333op/s; -564.819op/s] or [-5.615%; -0.331%]
scenario:only-tracing-dsm-enabled-benchmarks/KafkaProduceBenchmark.benchProduce same

@pr-commenter

pr-commenter Bot commented Dec 1, 2026

Copy link
Copy Markdown

Kafka / consumer-benchmark

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch dougqh/memoizer-member-prefilter dougqh/compiled-member-matchers
git_commit_date 1796093338 1796094970
git_commit_sha 3ed590e 0545b31
See matching parameters
Baseline Candidate
ci_job_date 1796096039 1796096039
ci_job_id 2313372901 2313372901
ci_pipeline_id 157101247 157101247
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
jdkVersion 11.0.31 11.0.31
jmhVersion 1.36 1.36
jvm /usr/lib/jvm/java-11-openjdk-amd64/bin/java /usr/lib/jvm/java-11-openjdk-amd64/bin/java
jvmArgs -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=15002 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=15002 -Dhttp.nonProxyHosts=localhost *.localhost
kernel_version Linux runner-zfyrx7zua-project-304-concurrent-0-sb70b0ye 6.8.0-1031-aws #33~22.04.1-Ubuntu SMP Thu Jun 26 14:22:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux Linux runner-zfyrx7zua-project-304-concurrent-0-sb70b0ye 6.8.0-1031-aws #33~22.04.1-Ubuntu SMP Thu Jun 26 14:22:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
vmName OpenJDK 64-Bit Server VM OpenJDK 64-Bit Server VM
vmVersion 11.0.31+11-post-1ubuntu1-22.04.2-Ubuntu 11.0.31+11-post-1ubuntu1-22.04.2-Ubuntu

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 3 metrics, 0 unstable metrics.

See unchanged results
scenario Δ mean throughput
scenario:not-instrumented/KafkaConsumerBenchmark.benchConsume same
scenario:only-tracing-dsm-disabled-benchmarks/KafkaConsumerBenchmark.benchConsume same
scenario:only-tracing-dsm-enabled-benchmarks/KafkaConsumerBenchmark.benchConsume same

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: core Tracer core tag: ai generated Largely based on code generated by an AI or LLM tag: no release notes Changes to exclude from release notes tag: performance Performance related changes type: refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant