Skip to content

Add a late-attach Kafka benchmark that times the JIT invalidations an attach causes (macrobenchmark) - #13769

Draft
dougqh wants to merge 3 commits into
masterfrom
dougqh/kafka-bench-late-attach
Draft

dougqh wants to merge 3 commits into
masterfrom
dougqh/kafka-bench-late-attach

Conversation

@dougqh

@dougqh dougqh commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

What Does This Do

Adds run-late-attach.sh to the Kafka macro benchmark. It attaches the agent to a consumer that is already warm, keeps consuming past the consumer's next periodic metadata refresh, and reports what each event costs:

  • attach: the agent arrives and retransforms the Kafka classes the warm consumer already uses;
  • late: the first thing after the attach that can throw compiled code away again. That's lookup-based header access becoming available (Read fetched Kafka headers without copying them first #13737), or else the first metadata refresh after the attach, so other agents get the same window.

For each event it reports which Kafka, tracer and benchmark methods the JIT invalidates (made not entrant, flagging the app's own code), the worst second, the throughput lost over the next 30 s, and the time to recover.

New files in dd-java-agent/benchmark-integration/kafka/:

  • LateAttachConsumer.java: a consumer that reads the prefilled topic in a loop and writes throughput for each second of JVM uptime. It also logs when the agent's classes appear and when RecordHeaderAccess.access changes.
  • Attach.java: loads an agent jar into a running JVM.
  • run-late-attach.sh: starts the shared Agent stub (../agent-stub, a real Agent's /info) when no Agent listens on TRACE_AGENT_PORT, and runs the variants (NoAgent or label=agent.jar) with order rotating every rep. It captures -XX:+PrintCompilation, GC logs and Kafka's metadata updates (DEBUG, shifted onto JVM uptime) for each run.
  • AnalyzeLateAttach.java: lines the throughput series, events, metadata refreshes and invalidations up per run.

Motivation

Measures the late-attach path discussed in #13737 and #13656, the case lookup-based header access is designed to support. That PR's benchmarks cover steady state with the agent present from startup, so this fills the gap.

Additional Notes

  • Uses the local broker and prefilled topic from broker.sh / prefill.sh, not Add a one-command containerized Kafka benchmark (macrobenchmark) #13757's containers: the Speedlab workload behind those can't attach an agent mid-run without a change there.
  • The kafka-clients-3.8 instrumentation needs JDK 17+.
  • Defaults: 60 s warm-up, Kafka's default 5-minute metadata.max.age.ms, 8-minute runs, 3 reps. METADATA_MAX_AGE_MS shortens runs for a quick look, but the refresh has to land well after the attach has settled to separate the two events.
  • The agent's settings are passed as system properties at JVM start, without -javaagent. The tracer reads them when it initializes after the attach.
  • First result (JDK 17, one rep, 3-minute refresh): see Read fetched Kafka headers without copying them first #13737 (comment).

🤖 Generated with Claude Code

dougqh and others added 2 commits December 1, 2026 23:59
… attach causes

Attaches the agent to an already-warm consumer, keeps consuming past the next
periodic metadata refresh, and reports throughput per second against the JIT's
made-not-entrant events around the attach and around the refresh (where
lookup-based header access becomes available).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without one, every trace send fails and the tracer runs its error path in every
arm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dougqh dougqh added type: feature Enhancements and improvements tag: no release notes Changes to exclude from release notes inst: kafka Kafka instrumentation comp: tooling Build & Tooling tag: ai generated Largely based on code generated by an AI or LLM labels Dec 2, 2026
The shared stub serves a real Agent's /info, so the tracer computes client-side
stats and drops unsampled traces as in production; the local one 404'd /info.
Also record what the stub received per endpoint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dd-octo-sts

dd-octo-sts Bot commented Dec 2, 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.12 s 14.10 s [-0.7%; +1.0%] (no difference)
startup:insecure-bank:tracing:Agent 13.08 s 13.12 s [-1.0%; +0.4%] (no difference)
startup:petclinic:appsec:Agent 17.39 s 17.21 s [+0.3%; +1.8%] (maybe worse)
startup:petclinic:iast:Agent 17.19 s 17.21 s [-0.9%; +0.6%] (no difference)
startup:petclinic:profiling:Agent 16.65 s 17.00 s [-3.1%; -1.1%] (significantly better)
startup:petclinic:sca:Agent 17.26 s 17.12 s [+0.1%; +1.6%] (maybe worse)
startup:petclinic:tracing:Agent 16.34 s 15.98 s [-2.1%; +6.6%] (no difference)

Commit: b94e35bd · 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.

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: tooling Build & Tooling inst: kafka Kafka instrumentation tag: ai generated Largely based on code generated by an AI or LLM tag: no release notes Changes to exclude from release notes type: feature Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant