Repository navigation
Add a dense known-tag store behind an experimental flag (dense store - part 8) - #13004
Conversation
🟢 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. |
08a9f3e to
1ba012a
Compare
1ba012a to
ab144fe
Compare
ab144fe to
ec5c752
Compare
0aba9cb to
8b1ccaa
Compare
8b1ccaa to
a921ebb
Compare
|
@amarziali both points are addressed in b110659, with cross-store parity tests. Could you take another look when you have a moment? |
There was a problem hiding this comment.
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.
🤖 Bits Code Review · Commit b110659
b110659 to
1f7a031
Compare
There was a problem hiding this comment.
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.
🤖 Bits Code Review · Commit 760509f
There was a problem hiding this comment.
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.
🤖 Bits Code Review · Commit 4b13541
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>
4b13541 to
63c60dd
Compare
There was a problem hiding this comment.
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.
🤖 Bits Code Review · Commit 63c60dd
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
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.Entryper tag. It reads through to the frozen parent's store, likeHashIdStore.DenseIdStore, not theIdStorebase, so spans with the flag off don't carry them.KnownTagCodec.idOf, backed by a generatedIDS_BY_SERIALtable.IdStoreFactorypicks the store once from the flag. Only oneIdStoresubclass loads, so class hierarchy analysis devirtualizes every call on it without an inline guard condition.DenseIdStoreForkedTestchecks thatHashIdStoreisn't loaded when the flag is on.Motivation
Most of a span's tag allocation is an
Entryper 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):legacy: every tag by namenormal: the calls today's decorators makenewApi: prototype at construction, tags by idEntry. Presizing from per-operation hints comes in Add singleSpanBuilder(SpanPrototype) (dense store - part 11) #12926.Tests:
Testtask through a Gradle init script, because tests don't see realDD_environment variables. In that mode, 16 Spock specs in internal-api (normalizers, telemetry) stop at a harness guard that rejects anydd.*system property at startup, so they didn't run there.TracerConnectionReliabilityTestcases, which need Docker.IdStoreContractTestruns both stores against the same contract, andTagStoresTest's tombstone check now works with either store.Where this is going
This PR is one step in replacing the span's single
TagMapwith 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
TagMapbecomes a thin view for code outside the span.Entryobject per tag, and each span's store is presized from a per-operation hint. With the flag on, a web-request-shaped trace allocates about 30% less on the application thread than on master.TagStore, not aTagMap. That covers post-processors now and serializers later, so noTagMapview gets built for them.TagStorehas its own verbs,loadandstore, apart fromTagMap'sget/setand the span's interceptedgetTag/setTag, soDDSpanContextcan offer both. The tag stores themselves use the same verbs (Add id and name tag stores, not yet used (dense store - part 5) #13006). It starts with what the eager processors use, by name and by id, and grows typed-load and primitive-store variants. Its intercepted counterpart,SpanData(Take the span's tag lock once in setTagsFrom (tag api - part 1) #13030), is whatsetTagsFrom,TagContributorandTagExtractortake, with one lock per batch.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.
TagMap. This is the stack's only behavior change, kept separate on purpose.TagMap, and addTraceShapeBenchmarkTagStorefor the eager post-processorsTagMap's bucket mechanics intoHashSupport(a pure move)TagMapa facade over the two storestrace.experimental.dense.tags.enabled(off by default)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 (
ThreadMXBeanallocated bytes, JDK 25) that buildsTraceShapeBenchmark's 7-span trace and, like serialization, feeds each span's size back into the sizing hints. The #12992 figure comes fromTraceShapeBenchmarkitself.🤖 Generated with Claude Code