Repository navigation
Avoid redundant allocations in V1 trace serialization - #13481
AlexeyKuznetsov-DD wants to merge 3 commits into
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
More details
Static review supports preserved V1 payload encoding, string-table deduplication across value types, and tag traversal behavior. Allocation and timing improvements were not measured by this review.
🤖 Bits Code Review · Commit 824bf48
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 824bf4851a
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
What Does This Do
Avoid redundant UTF-8 encoding and tag-iterator allocation when serializing traces with the V1 intake protocol. Preserve the existing payload representation and string-table deduplication across value types.
Motivation
The V1 serializer converted pre-encoded strings to plain Strings before writing them, losing the cached UTF-8 encoding. Its two tag passes also created iterators for every span. These costs repeat across every serialized batch.
Additional Notes
The mapper retains String keys for content-based deduplication, but passes UTF8BytesString values directly to the writer on string-table misses. Tag counting and writing use callbacks with explicit state, and empty baggage and meta-struct maps skip entry-set traversal.
Related precedent: #13096 introduced the chunked serialization buffer used by this benchmark path.
Regression coverage verifies the UTF-8 writer path and decoded values for span and event attributes, cached HTTP status codes, explicit-status precedence, null-status fallback, and legacy event-tag exclusion.
Validation:
./gradlew :dd-trace-core:test --tests datadog.trace.common.writer.ddagent.TraceMapperV1PayloadTest— 39 tests passed.Benchmark comparison at 1,000 traces per payload
The baseline run uses master without this patch; the optimized run includes the known-tag ID and HTTP-status presence-check follow-ups. Each payload contains 1,000 traces and 4,000 spans. The v0.4 column comes from the master run.
Both percentage columns measure the change to V1 optimized:
(V1 optimized / baseline - 1) * 100. Negative values mean optimized V1 uses less.Allocation — KiB per payload
Serialization time — microseconds per payload
Allocation is calculated from JMH
gc.alloc.rate.norm / 1024; cold allocation includes URL-refresh setup. Warm runs reuse URL values.These are observed results from separate runs, with one measurement per configuration and no reported error estimates. The unchanged v0.4 control varied by -18.3% to +39.0% in time between runs, so timing differences should be treated as directional. The summaries do not record the JDK, JVM flags, exact revisions, or complete benchmark settings; full run provenance is still needed to establish a controlled before/after comparison.
Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issueJira ticket: N/A