Skip to content

Add a Kafka macro benchmark running Kafka's perf tools under the agent (macrobenchmark) - #13051

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 5 commits into
masterfrom
dougqh/kafka-macro-benchmark
Nov 3, 2026
Merged

gh-worker-dd-mergequeue-cf854d[bot] merged 5 commits into
masterfrom
dougqh/kafka-macro-benchmark

Conversation

@dougqh

@dougqh dougqh commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds a self-contained Kafka macro benchmark under dd-java-agent/benchmark-integration/kafka/. It runs Kafka's own perf tools (kafka-consumer-perf-test and kafka-producer-perf-test) under the agent.

The tools use the standard kafka-clients library, so the agent's Kafka instrumentation runs on the real client paths with no application code.

script does
fetch-kafka.sh Apache Kafka 3.9.1, SHA-512 verified, unpacked under build/
broker.sh start|stop single-node KRaft broker, without the agent
prefill.sh fills the consume topic using an agent-instrumented producer, so every record carries real trace headers (Datadog, W3C traceparent / tracestate)
preflight.sh checks that the producer injects headers and that the consumer continues the producer's trace
run-consumer.sh / run-producer.sh variants (NoAgent or label=agent.jar), fresh JVM per run, rotated order, heap sweep, GC logs, CSV
Analyze.java single-file Java program run by both runners. Consumer, per heap and variant: median throughput (with every run shown), the tracer's µs per record vs NoAgent, change vs a baseline, young GCs per million records. Producer: median rate and latency percentiles. Rejected runs (nonzero exit, short consumer read, missing producer summary) are counted and left out of the medians

Motivation

  • The consumer does almost no work per record, so the tracer's per-message cost is a large share of the work. That makes this a sensitive, low-noise probe: about ±2–3% run to run, and builds with real differences don't overlap.
  • Every consumed record goes through extraction, because the topic carries real trace headers. Propagation work is exercised the way an upstream producer exercises it in production.
  • The absolute cost per record is the portable number. Throughput relative to NoAgent says more about how little the consumer does than about the tracer.

Example results from one laptop (JDK 17, 10M records, 5 reps), consumer fetch records/s at 256m:

NoAgent master dense-store stack trace-segment stack both stacks
1447k 288k 301k (+4.6%) 326k (+13.2%) 331k (+15.0%)

The same workload exposed per-record Data Streams work done with DSM disabled; skipping it adds ~6.6%. More detail is in the README.

Additional Notes

  • Tooling only; no production code changes.
  • Tested end to end locally: fetch, broker, prefill, preflight, and consumer/producer runs with small sizes.
  • Intended to become a regression gate later (tracer cost per record vs a per-release baseline) on dedicated hosts.

🤖 Generated with Claude Code

dougqh and others added 2 commits October 25, 2026 14:24
kafka-consumer-perf-test / kafka-producer-perf-test use the standard
kafka-clients library, so the agent's Kafka instrumentation runs on the real
client paths with no application code. The consume topic is filled by an
agent-instrumented producer, so every record carries trace headers and each
consumed record goes through extraction and gets a consume span.

Scripts: fetch (SHA-512 verified), single-node KRaft broker without the agent,
topic prefill, a preflight that checks header injection and trace
continuation, consumer and producer runs (fresh JVM per run, rotated variant
order, heap sweep, GC logs, CSV), and an analysis that reports the tracer's
cost per record against NoAgent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dougqh dougqh added 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 labels Oct 25, 2026
@dd-octo-sts

dd-octo-sts Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

🟡 Java Benchmark SLOs — Performance SLO warning (near threshold)

Suite Status
Startup 🟡 warning

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 13.95 s 13.95 s [-0.7%; +0.6%] (no difference)
startup:insecure-bank:tracing:Agent 12.84 s 12.95 s [-1.4%; -0.3%] (maybe better)
startup:petclinic:appsec:Agent 17.79 s 17.64 s [-0.0%; +1.8%] (no difference)
startup:petclinic:iast:Agent 17.54 s 17.64 s [-1.5%; +0.3%] (no difference)
startup:petclinic:profiling:Agent 17.46 s 17.35 s [-0.4%; +1.7%] (no difference)
startup:petclinic:sca:Agent 17.82 s 17.74 s [-0.7%; +1.6%] (no difference)
startup:petclinic:tracing:Agent 16.66 s 16.82 s [-1.8%; -0.0%] (maybe better)

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

@dougqh
dougqh marked this pull request as ready for review October 27, 2026 14:52
@dougqh
dougqh requested a review from a team as a code owner October 27, 2026 14:52
@dougqh
dougqh requested review from AlexeyKuznetsov-DD and removed request for a team October 27, 2026 14:52
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T15:00:50.623757Z 7b270d6 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7b270d6b1d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@datadog-prod-us1-4 datadog-prod-us1-4 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: FAIL

Benchmark shutdown can terminate unrelated local Kafka brokers. Both runners can also accept incomplete executions as benchmark results, distorting throughput comparisons or producing malformed CSV.

Open Bits AI session

🤖 Bits Code Review · Commit 7b270d6

@AlexeyKuznetsov-DD AlexeyKuznetsov-DD left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about to use Java instead of Python?

dougqh and others added 2 commits October 27, 2026 17:29
…oker

broker.sh stop now signals the PID it recorded instead of running
kafka-server-stop.sh, which stops every Kafka broker on the host.

run-consumer.sh rejects runs that exit nonzero or read fewer than
MESSAGES records; a short read still prints stats after the timeout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Analyze.java runs as a single-file source program on the JDK the
benchmark already requires, replacing analyze.py and the python3
dependency. It also summarizes producer results and reports rejected
runs per variant.

run-producer.sh now requires the final summary line (the only one with
percentiles) and a zero exit, and records rejected runs as empty rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@datadog-prod-us1-4

datadog-prod-us1-4 Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 59.99% (-0.02%)

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

@AlexeyKuznetsov-DD

Copy link
Copy Markdown
Contributor

--- found with Codex

P2: Reject partial producer runs

In run-producer.sh, lines 35–43, a zero exit and final summary are sufficient for acceptance. However, Kafka 3.9.1's producer callback prints asynchronous send errors without failing the process; its final summary counts only successful sends. A partially failed workload therefore enters the medians.

I reproduced this with the unchanged runner and a stubbed perf tool: requesting 100 records and returning a zero exit plus a final summary for 90 records produced an accepted CSV measurement.

Please parse the successful-record count from the final summary and require it to equal RECORDS before accepting the run.

This extends the existing producer-summary concern: the earlier fix correctly rejects nonzero exits and missing final summaries, but does not cover asynchronous send failures.

@AlexeyKuznetsov-DD AlexeyKuznetsov-DD left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice to see that java can replace python for analyzing data.
Left minor comment found by Codex.

Kafka's producer perf tool logs failed sends without failing and its summary counts only the
successful ones, so a run is now accepted only if it sent every record.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dougqh

dougqh commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Thanks — the partial-producer-run P2 is fixed in a5ab030. run-producer.sh now reads the sent count from the final summary and rejects the run unless it equals RECORDS. With a stubbed perf tool reporting 90 of 100 records sent, the run is rejected (FAIL r1-noagent: exit 0, sent 90 of 100) and excluded from the medians; 100 of 100 is accepted. The README's rejection rules mention it too.

Reply written by Claude (Claude Code) on behalf of dougqh.

@dougqh
dougqh enabled auto-merge November 3, 2026 20:55
@dougqh
dougqh added this pull request to the merge queue Nov 3, 2026
@dd-octo-sts

dd-octo-sts Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-11-03 21:42:20 UTC ℹ️ Start processing command /merge


2026-11-03 21:42:24 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 2h (p90).


2026-11-03 22:33:24 UTC ℹ️ MergeQueue: This merge request was merged

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 3, 2026
@dougqh

dougqh commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-11-03 22:01:34 UTC ℹ️ Start processing command /merge


2026-11-03 22:01:37 UTC ❌ MergeQueue

PR already in the queue with status in_progress

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 6f44bc9 into master Nov 3, 2026
656 of 658 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the dougqh/kafka-macro-benchmark branch November 3, 2026 22:33
@github-actions github-actions Bot added this to the 1.69.0 milestone Nov 3, 2026
@dougqh dougqh changed the title Add a Kafka macro benchmark running Kafka's perf tools under the agent (perf toolbox - benchmark) Add a Kafka macro benchmark running Kafka's perf tools under the agent (macrobenchmark) Nov 4, 2026
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.

2 participants