Skip to content

Serialize DSM payloads into a chunked buffer - #13107

Draft
dougqh wants to merge 1 commit into
dougqh/chunked-dsm-statsfrom
dougqh/chunked-dsm
Draft

dougqh wants to merge 1 commit into
dougqh/chunked-dsm-statsfrom
dougqh/chunked-dsm

Conversation

@dougqh

@dougqh dougqh commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

What Does This Do

Moves the Data Streams Monitoring payload writer (MsgPackDatastreamsPayloadWriter) off its 512 KiB GrowableBuffer and onto the chunked buffer. Stacked on #13097 ("Serialize client stats payloads into a chunked buffer"), which adds the small-chunk default and makes Sink take a payload as chunks.

  • Uses a ChunkedStreamingBuffer with a 5 MiB cap.
  • Nothing is allocated until the first payload, so DSM off costs no buffer. A payload of a few KB keeps a few KB.
  • A payload over the cap is dropped with a debug log instead of growing without bound. The first write past the cap throws, the writer catches it, and mark() reports the drop.
  • Removes the single-buffer Sink.accept default that Serialize client stats payloads into a chunked buffer #13097 kept for this writer.

Motivation

DefaultDataStreamsMonitoring builds this writer whether or not Data Streams is enabled, and the writer allocated its 512 KiB buffer right away. With DSM off (the default), the buffer was never written to: in a heap dump of Spring PetClinic it was all zeros.

512 KiB plus the 16-byte array header is just over half a 1 MB G1 region, so it was a humongous object on heaps up to about 2 GB, pinned in old gen for the tracer's lifetime. It was one of the five humongous regions the agent held after #13096. With #13097, three remain, all from the agent jar's central directory (APMLP-2161). The full measurement is in #13097.

This is the memory side of the same pattern as the recent DSM guard PRs: work done for Data Streams while it's off.

Additional Notes

MsgPackDatastreamsPayloadWriterTest covers the cap: a payload one byte over is dropped without throwing, and one at the cap is sent.

Jira ticket: APMLP-2159

🤖 Generated with Claude Code

@dougqh dougqh added type: feature Enhancements and improvements tag: performance Performance related changes comp: data streams Data Streams Monitoring tag: ai generated Largely based on code generated by an AI or LLM labels Oct 28, 2026
@datadog-official

datadog-official Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 59.33% (+0.01%)

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

@dd-octo-sts

dd-octo-sts Bot commented Oct 28, 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 13.96 s 13.98 s [-0.9%; +0.7%] (no difference)
startup:insecure-bank:tracing:Agent 12.88 s 12.99 s [-1.5%; -0.1%] (maybe better)
startup:petclinic:appsec:Agent 17.77 s 16.93 s [+0.5%; +9.5%] (maybe worse)
startup:petclinic:iast:Agent 17.54 s 17.63 s [-1.4%; +0.3%] (no difference)
startup:petclinic:profiling:Agent 17.48 s 17.31 s [-0.3%; +2.2%] (no difference)
startup:petclinic:sca:Agent 17.75 s 17.62 s [-0.1%; +1.6%] (no difference)
startup:petclinic:tracing:Agent 16.64 s 16.79 s [-1.8%; +0.0%] (no difference)

Commit: b1bc2cd9 · 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 Oct 28, 2026 •

Copy link
Copy Markdown

Kafka / producer-benchmark

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch dougqh/chunked-dsm-stats dougqh/chunked-dsm
git_commit_date 1793363894 1793363896
git_commit_sha dcc3b8d b1bc2cd
See matching parameters
Baseline Candidate
ci_job_date 1793370563 1793370563
ci_job_id 2196136618 2196136618
ci_pipeline_id 148944109 148944109
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-1-215uhtwo 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-1-215uhtwo 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 1 performance improvements and 0 performance regressions! Performance is the same for 2 metrics, 0 unstable metrics.

scenario Δ mean throughput
scenario:only-tracing-dsm-disabled-benchmarks/KafkaProduceBenchmark.benchProduce better
[+1956.480op/s; +10758.916op/s] or [+1.266%; +6.962%]
See unchanged results
scenario Δ mean throughput
scenario:not-instrumented/KafkaProduceBenchmark.benchProduce same
scenario:only-tracing-dsm-enabled-benchmarks/KafkaProduceBenchmark.benchProduce same

@pr-commenter

pr-commenter Bot commented Oct 28, 2026

Copy link
Copy Markdown

Kafka / consumer-benchmark

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch dougqh/chunked-dsm-stats dougqh/chunked-dsm
git_commit_date 1793192792 1793192806
git_commit_sha 6a35550 9a3c468
See matching parameters
Baseline Candidate
ci_job_date 1793194641 1793194641
ci_job_id 2185362561 2185362561
ci_pipeline_id 148181666 148181666
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-o6p13ho7 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-o6p13ho7 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

MsgPackDatastreamsPayloadWriter held a 512 KiB GrowableBuffer for the
tracer's lifetime, allocated when DefaultDataStreamsMonitoring is built
- even with Data Streams off, where it was never written to. It was a
G1 humongous object on heaps up to about 2 GB.

It now uses a ChunkedStreamingBuffer with a 5 MiB cap: nothing is
allocated until the first payload, so DSM off costs no buffer, and a
payload of a few KB keeps a few KB. A payload over the cap is dropped
with a debug log instead of growing without bound.

Sink loses its single-buffer default, which only this writer used.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dougqh
dougqh force-pushed the dougqh/chunked-dsm-stats branch from 6a35550 to dcc3b8d Compare October 30, 2026 14:06
@dougqh
dougqh force-pushed the dougqh/chunked-dsm branch from 9a3c468 to b1bc2cd Compare October 30, 2026 14:06

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: data streams Data Streams Monitoring tag: ai generated Largely based on code generated by an AI or LLM tag: performance Performance related changes type: feature Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant