Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Injecting a relayed trace writes its tracestate's unparsed ot member, after checking that parsing it under the pending sampling checks would leave it unchanged. That check (hex scans of rv and th, a threshold parse) ran twice per injected header, once for the size estimate and once for the write, and again on every injection, because nothing kept the answer. In a Kafka enricher profile it was about 40% of the tracer's inject time. W3CTracestate now keeps the answer per pending-check combination in a byte, like the raw member's position is already kept. TracestateRelayBenchmark.relay, 3 forks x 5 iterations: withOtel 706 -> 628 ns/op (-11%), ddOnly unchanged within noise, allocation unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Contributor
🟢 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. |
This was referenced Nov 24, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Does This Do
Remembers, per pending-check combination, whether an inherited
ottracestate member comes out unchanged under the sampling consistency checks. Injection then doesn't redo that check for every header it writes.Motivation
When a trace is relayed (a Datadog context with a lower-priority
tracestatemerged in, as for every Kafka consume → produce record), injection writes the unparsedotmember back. First it confirms that parsing the member and applying the pending checks would leave it unchanged: hex scans ofrvandth, plus a threshold parse. That check:tracestate, once fromestimateHeaderSizeand once fromappendOtelAndVendorMembers,In a JFR profile of a Kafka enricher, it was about 40% of the tracer's inject time (about 146 of 380 inject samples).
W3CTracestatealready remembers the raw member's position the same way (rawPosition). This adds the equivalent for the unchanged check: 4 "checked" and 4 "unchanged" bits in one byte. Racing writers can only drop each other's bits, which costs a recheck, never a wrong answer.Results
New
TracestateRelayBenchmark(single thread; one op = one relayed trace: parsex-datadog-tags, merge thetracestateat lower priority, encode the outboundtracestate). It's committed separately, before the fix, so both sides run the same benchmark. 3 forks × 5 iterations, stable per fork:withOtelddOnlyThe written output is byte-identical: only the repeated check is gone.
End to end (Kafka enricher, 10% sampling, 5 rotated reps): a combined build with #13662 and #13664 on the 4i roll-up cuts tracer cost per record from 3.53 to 3.36 µs at 1g (+3.5% throughput) and from 4.89 to 4.70 µs at 96m (+3.2%); 4j beat 4i in 8 of 10 paired reps. The two PRs were measured together, so this is their combined effect. The consumer, which doesn't inject, is flat (2.56 vs 2.58 µs at 1g).
Additional Notes
OtelMemberForWriteTestgains a test that writes one instance under every check combination twice, so the second pass reads remembered answers and must still match a fresh parse for each combination.x-datadog-tagspassthrough). The two are independent.🤖 Generated with Claude Code