Skip to content

Add a dense known-tag store behind an experimental flag (dense store - part 8) - #13004

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits into
masterfrom
dougqh/tagmap-dense-id-store
Nov 17, 2026
Merged

gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits into
masterfrom
dougqh/tagmap-dense-id-store

Conversation

@dougqh

@dougqh dougqh commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

What Does This Do

Adds DenseIdStore, a second implementation of the known-tag store, behind an experimental flag: trace.experimental.dense.tags.enabled (DD_TRACE_EXPERIMENTAL_DENSE_TAGS_ENABLED), off by default.

  • Layout: two parallel arrays hold each tag's 16-bit serial and its value, with no Entry per tag. It reads through to the frozen parent's store, like HashIdStore.
  • Lookups: a lookup scans the serials. Slot and level mask words skip the scan when they rule the tag out. The masks live in DenseIdStore, not the IdStore base, so spans with the flag off don't carry them.
  • Ids: the full id is rebuilt from the serial only when a reader asks for it. That uses KnownTagCodec.idOf, backed by a generated IDS_BY_SERIAL table.
  • Removal: removing a tag that hides nothing inherited swaps the last slot into its place. Hiding an inherited tag stores a shared tombstone instead.
  • One store class per JVM: IdStoreFactory picks the store once from the flag. Only one IdStore subclass loads, so class hierarchy analysis devirtualizes every call on it without an inline guard condition. DenseIdStoreForkedTest checks that HashIdStore isn't loaded when the flag is on.

Motivation

Most of a span's tag allocation is an Entry per known tag. The dense store drops those. #12926, stacked on this PR, turns it on by default and adds per-operation sizing hints and bulk prototype seeding.

Additional Notes

Allocation, 7-span web-request trace, application thread only (JDK 25, per-thread allocated bytes, TraceShapeBenchmark's shapes):

arm master flag off flag on
legacy: every tag by name 8,104 B 7,992 B 5,616 B (−30.7%)
normal: the calls today's decorators make 7,432 B 7,320 B 5,872 B (−21.0%)
newApi: prototype at construction, tags by id 7,432 B 7,320 B 5,872 B (−21.0%)

Tests:

  • Flag off: internal-api passes, including the forked dense test, and so do the build-logic generator tests.
  • Flag on: dd-trace-core and internal-api pass. The flag was set as a system property on every Test task through a Gradle init script, because tests don't see real DD_ environment variables. In that mode, 16 Spock specs in internal-api (normalizers, telemetry) stop at a harness guard that rejects any dd.* system property at startup, so they didn't run there.
  • Both modes: the only other failures are the two TracerConnectionReliabilityTest cases, which need Docker.
  • IdStoreContractTest runs both stores against the same contract, and TagStoresTest's tombstone check now works with either store.

Where this is going

This PR is one step in replacing the span's single TagMap with storage that knows each tag's kind. The goal is to cut what every span allocates on the application thread, without changing behavior.

The end state

Later, not in this stack: cheaper read-through to parent spans, trace-level tags in a per-trace holder (TraceSegment), and primitive tag values without boxing.

The stack. This replaces #12918, split into pieces that can each be reviewed, and measured, on their own.

PR Step Allocation per 7-span trace (flag off unless noted)
#12999 (merged) A null tag value removes the tag in TagMap. This is the stack's only behavior change, kept separate on purpose. unchanged
#12992 (merged) Bucket known tags by slot in TagMap, and add TraceShapeBenchmark −96 B vs master
#13001 (merged) TagStore for the eager post-processors unchanged
#13002 (merged) Extract TagMap's bucket mechanics into HashSupport (a pure move) unchanged
#13006 (merged) Add the id and name tag stores, not yet used unchanged
#13007 (merged) Make TagMap a facade over the two stores unchanged
#13003 Have the span own its tag stores directly −112 B (−1.5%)
#13004 Dense id store behind trace.experimental.dense.tags.enabled (off by default) flag on: −21% (decorator calls) to −31% (tags by name)
#12926 Turn the dense store on by default, add sizing hints and bulk prototype seeding flag on: −26% to −33% vs master, about 6% less than #13004

Every PR after #12999 is behavior-preserving.

The #13003, #13004 and #12926 figures were re-measured on 2026-11-03, after #13006 and #13007 merged, with a deterministic per-thread probe (ThreadMXBean allocated bytes, JDK 25) that builds TraceShapeBenchmark's 7-span trace and, like serialization, feeds each span's size back into the sizing hints. The #12992 figure comes from TraceShapeBenchmark itself.

🤖 Generated with Claude Code

@datadog-datadog-us1-prod

datadog-datadog-us1-prod Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

🎯 Code Coverage (details)
• Patch Coverage: 90.29%
• Overall Coverage: 60.53% (+0.08%)

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

@dd-octo-sts

dd-octo-sts Bot commented Oct 23, 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 14.91 s 14.68 s [+0.7%; +2.5%] (maybe worse)
startup:insecure-bank:tracing:Agent 13.55 s 13.73 s [-2.1%; -0.5%] (maybe better)
startup:petclinic:appsec:Agent 17.21 s 16.51 s [-0.4%; +8.8%] (no difference)
startup:petclinic:iast:Agent 17.04 s 16.93 s [-0.3%; +1.5%] (no difference)
startup:petclinic:profiling:Agent 16.50 s 16.68 s [-2.1%; +0.0%] (no difference)
startup:petclinic:sca:Agent 17.05 s 17.03 s [-0.8%; +1.1%] (no difference)
startup:petclinic:tracing:Agent 16.16 s 16.24 s [-1.3%; +0.2%] (no difference)

Commit: 63c60dd1 · 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 force-pushed the dougqh/tagmap-dense-id-store branch from 08a9f3e to 1ba012a Compare October 23, 2026 04:16
@dougqh dougqh changed the title Add a dense known-tag store behind an experimental flag Add a dense known-tag store behind an experimental flag (dense store - part 8) Oct 23, 2026
@bric3
bric3 added this pull request to stack #13019 October 23, 2026 16:02
@dougqh
dougqh force-pushed the dougqh/tagmap-dense-id-store branch from 1ba012a to ab144fe Compare October 23, 2026 16:57
@dougqh
dougqh force-pushed the dougqh/tagmap-dense-id-store branch from ab144fe to ec5c752 Compare October 26, 2026 16:08
@dougqh
dougqh force-pushed the dougqh/tagmap-dense-id-store branch from 0aba9cb to 8b1ccaa Compare November 2, 2026 21:56
@dougqh
dougqh force-pushed the dougqh/tagmap-dense-id-store branch from 8b1ccaa to a921ebb Compare November 3, 2026 16:05
@dougqh

dougqh commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

@amarziali both points are addressed in b110659, with cross-store parity tests. Could you take another look when you have a moment?

@dougqh
dougqh requested review from a team as code owners November 6, 2026 17:49
@dougqh
dougqh requested review from ygree and removed request for a team November 6, 2026 17:49

@datadog-datadog-us1-prod datadog-datadog-us1-prod 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

Null-valued bulk tag writes can leave null entries instead of removing tags, even with dense storage disabled. With builder-tag precedence enabled, OTLP exports also omit root-only tags moved into the inherited store.

Open Bits AI session

🤖 Bits Code Review · Commit b110659

@dougqh
dougqh force-pushed the dougqh/tagmap-dense-id-store branch from b110659 to 1f7a031 Compare November 6, 2026 18:04
@gh-worker-ownership-write-b05516
gh-worker-ownership-write-b05516 Bot removed the request for review from a team November 10, 2026 16:47

@datadog-datadog-us1-prod datadog-datadog-us1-prod 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

With dense storage enabled, removing a known tag can leave its payload retained by the store’s cached reader. The unresolved retention concern in the human discussion is supported by the supplied head, allowing large removed values to remain attached to long-lived spans.

Open Bits AI session

🤖 Bits Code Review · Commit 760509f

@datadog-datadog-us1-prod datadog-datadog-us1-prod 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: PASS

More details

The PR adds an opt-in dense known-tag store while retaining the hash backend by default. The update resolves the earlier payload-retention defect by removing cached readers and separating removal from get-and-remove; no findings remain open, with validation limited to static inspection because tests were not executed and production telemetry was excluded.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 4b13541

Base automatically changed from dougqh/tagmap-split-known-custom to master November 17, 2026 14:07
dougqh and others added 4 commits November 17, 2026 14:07
DenseIdStore keeps a span's known tags in two parallel arrays, each
tag's 16-bit serial and its value, with no Entry per tag. It reads
through to the frozen parent's store like HashIdStore. A lookup scans
the serials and is skipped when the slot and level masks rule the tag
out; the full id is rebuilt from the serial (KnownTagCodec.idOf, backed
by the generated IDS_BY_SERIAL table) only where a reader asks for it.

The masks live in DenseIdStore, which needs them to index its arrays.
HashIdStore's buckets are the exact state, so it stays without them and
dense-off spans keep their current size.

IdStoreFactory picks the store once per JVM from
trace.experimental.dense.tags.enabled (off by default), so only one
IdStore subclass is loaded and calls on it stay devirtualized.

TraceShape probe, 7-span trace: 8,040 B with the flag off (unchanged),
5,504 B with it on (-30% vs master).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The dense reader classifies and coerces through TagValueConversions,
which had drifted from Entry while nothing used it: it typed Short and
Byte as INT, said every value is(OBJECT), and coerced an OBJECT through
Number (BigDecimal("12") read as 12) or to false ("GET"). So the dense
flag could change what a tag read returned.

TagValueConversions now encodes Entry's rules for a boxed value: only
Boolean, Integer, Long, Float and Double are typed; anything else is an
OBJECT, which is true when present and 0 as a number. Its tests check
every conversion against an Entry of the same value, and the shared
IdStore contract test checks both stores' readers against Entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#13061 named an id after its tag with no _ID suffix. Rename only; the
ids are the same values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DenseIdStore answered put, getAndPut and remove with one reused reader
pointed at the prior value. A caller that discarded the result, as the span's
removal paths do, left that value reachable from the store until a later write
with a prior value replaced it: a removed error.stack could stay attached to a
long-lived span.

- remove and put now return nothing, as TagMap's naming suggests; callers that
  need the prior value use getAndRemove (new) and getAndPut. The span's
  removal and put paths build no reader at all.
- getAndPut and getAndRemove return a fresh reader instead of the reused one.
  That costs one 32-byte reader when there is a prior value; TagMap, their only
  caller, turns it into an Entry anyway.

IdStoreContractTest checks, for both stores, that a removed or replaced value
is collectable once the caller drops it; it fails with a reused reader.

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

@datadog-datadog-us1-prod datadog-datadog-us1-prod 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: PASS

More details

The dense backend remains opt-in, with shared contract coverage addressing the reader-coercion and removed-value-retention risks raised in the human discussion. Runtime behavior was not exercised in this review.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 63c60dd

@dougqh

dougqh commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

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

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-11-17 20:28:26 UTC ℹ️ Start processing command /merge


2026-11-17 20:28:30 UTC ℹ️ MergeQueue: pull request added to the queue

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


2026-11-17 21:32:26 UTC ℹ️ MergeQueue: This merge request was merged

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit d681811 into master Nov 17, 2026
685 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the dougqh/tagmap-dense-id-store branch November 17, 2026 21:32
@github-actions github-actions Bot added this to the 1.70.0 milestone Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: core Tracer core tag: ai generated Largely based on code generated by an AI or LLM type: feature Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants