Repository navigation
Conversation
The x-datadog-tags parse interned every key (TagKey.from) and compared it against a chain of ~13 known keys, cached every value, and parsed the tid twice: once to validate it, then again into the trace id's high bits. In a Kafka consumer profile that was ~12% of the consumer thread's tracer time. Known keys are now matched on the raw range by length, then characters, against the existing TagKey constants; only other _dd.p.* keys are interned. The tid is validated and parsed into a long in one pass, and its hex TagValue is made only when something reads it (injection, header size). Character validation uses lookup tables instead of IntPredicate method references. Accept/reject decisions, errors and the tags produced are unchanged; DatadogTagsKeyMatchingTest's rows were recorded against the previous parse. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
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 21, 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
Speeds up the
x-datadog-tagsparse on extraction. Known keys are matched by their characters instead of being interned, the_dd.p.tidvalue is validated and parsed into the trace id's high-order bits in one pass, and character validation uses lookup tables. Accept/reject decisions, propagation errors and the resulting tags are unchanged.Stacked on #13356.
Motivation
In a 30-minute CPU profile of a Kafka consumer (10% sampled upstream traces), parsing
x-datadog-tagswas ~12% of the consumer thread's tracer time. Within it: value caching 24%, character validation 21%, the loop and its chain of ~13TagKey.equals16%,tidvalidation (hex parse) 14%,TagKey.frominterning 13.5%, buildingPTags11%. A Datadog producer typically sends only_dd.p.dmand_dd.p.tid, and both are needed at extraction (the decision maker for the sampling state, the high-order bits for the trace id), so the gain has to come from parsing them more cheaply rather than deferring them.Additional Notes
_dd.p.*names (taken from the existingTagKeyconstants) by length, then characters. Only other_dd.p.*keys go throughTagKey.from. Keys without the prefix, or with nothing after it, are ignored as before._dd.p.tid: validated (16 lower-case hex digits) and parsed into alongonce, instead of being wrapped in a cachedTagValueand parsed again byPTags.PTagsmakes the hexTagValueon first read (injection, header size), published with a CAS that can't overwrite a concurrentupdateTraceIdHighOrderBits. An all-zerotidis still carried verbatim.scanreplacesvalidateCharsUntilSeparatorOrEndwith the same accepted sets and edge cases, from tables built from the existingisAllowedKeyChar/isAllowedValueChar, rather thanIntPredicatemethod references._dd.p.dm,_dd.p.ts, the org marker and the LLMObs tags keep their cached or uncachedTagValues, as before.DatadogPropagationTagsTest's malformed-tidrows).DatadogTagsKeyMatchingTestadds rows for what the raw matcher decides (prefix-only and unprefixed keys, a near-miss key, unknown keys,upstream_services, an all-zerotid, values containing=); its expectations were recorded by running it against the previous parse.PropagationTagsBenchmark/HeaderPathBenchmarkA/B to follow.🤖 Generated with Claude Code