Skip to content

Extract TagMap's bucket mechanics into HashSupport (dense store - part 4) - #13002

Draft
dougqh wants to merge 1 commit into
dougqh/eager-postprocessors-span-contextfrom
dougqh/tagmap-hash-support
Draft

dougqh wants to merge 1 commit into
dougqh/eager-postprocessors-span-contextfrom
dougqh/tagmap-hash-support

Conversation

@dougqh

@dougqh dougqh commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

What Does This Do

A pure move. TagMap's loops over one bucket array become static methods of a new HashSupport class, moved verbatim:

  • find, put, remove, copy and merge;
  • the forEach variants, fillMap and fillStringMap;
  • count, isEmpty, the bucket-position check and toInternalString.

Each method reports what it did through its return value: the entry that put replaced, the entry that remove removed, and how much merge grew the map. TagMap keeps its fields and its size counter, plus the read-through and tombstone handling around those calls.

Motivation

The next PR in the stack splits a span's tags into a known-tag store and a custom-tag store. Both reuse these mechanics, so this moves them out first and reviews the move on its own, separate from the split.

Additional Notes

  • No new objects or fields, and no behavior change. Allocation per trace matches the base, and the TagMap and core span suites pass unchanged.
  • The bucket-integrity check was copied as-is. It still has a pre-existing indexing bug (it uses the outer bucket index inside the group loop). The split PR next in the stack fixes it, so this one stays a verbatim move.

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

  • A tag is classified once, at the boundary. A known tag becomes an id (from the tag registry, Resolve direction-scoped OpenTelemetry names at the OpenTelemetry boundary (otlp - tag registry - phase 3) #12731), and a custom tag stays a name. Instrumentation sets known tags by id (Route intercepted tags by id instead of by name (otlp - tag registry - phase 3) #12817), so the JIT can constant-fold the routing.
  • The span owns its tag stores directly. Known tags are kept by id and custom tags by name. TagMap becomes a thin view for code outside the span.
  • Known tags live in a dense store by default. Parallel arrays of serials and values replace an Entry object 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.
  • Core reads and writes a span through SpanContents, not a TagMap. That covers post-processors now and serializers later, so no TagMap view gets built for them. SpanContents starts with four methods and grows a name, id and primitive API as more readers move to it.

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 A null tag value removes the tag in TagMap. This is the stack's only behavior change, kept separate on purpose. unchanged
#12992 Bucket known tags by slot in TagMap, and add TraceShapeBenchmark −96 B vs master
#13001 SpanContents for the eager post-processors unchanged
#13002 Extract TagMap's bucket mechanics into HashSupport (a pure move) unchanged
#13006 Add the id and name tag stores, not yet used unchanged
#13007 Make TagMap a facade over the two stores unchanged
#13003 Have the span own its tag stores directly +104 B (+1.3%)
#13004 Dense id store behind trace.experimental.dense.tags.enabled (off by default) flag on: −30.6%
#12926 Turn the dense store on by default, add sizing hints and bulk prototype seeding flag on: about 3% less again

Every PR after #12999 is behavior-preserving.

The pieces' allocation figures come from a deterministic per-thread probe (ThreadMXBean allocated bytes) that builds the same 7-span trace as TraceShapeBenchmark. The #12992 and #12926 figures come from TraceShapeBenchmark itself.

🤖 Generated with Claude Code

A pure move: the loops over one bucket array (find, put, remove, copy,
merge, the forEach variants, fillMap / fillStringMap, count, isEmpty,
the bucket-position check, toInternalString) become static methods of
HashSupport, moved verbatim. Each reports what it did through its
return value (the entry put replaced, the entry remove removed, how much
merge grew the map), and TagMap keeps its fields, its size counter, and
the read-through and tombstone handling around them.

No new objects or fields, and no behavior change: allocation per trace
in TraceShapeBenchmark matches the base within fork-to-fork noise, and
the TagMap and core span suites pass unchanged. This prepares the split
of known and custom tags into separate stores, which reuse these
mechanics.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@datadog-prod-us1-5

This comment has been minimized.

@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 13.96 s 13.91 s [-0.2%; +1.0%] (no difference)
startup:insecure-bank:tracing:Agent 12.95 s 12.99 s [-1.2%; +0.4%] (no difference)
startup:petclinic:appsec:Agent 17.18 s 17.07 s [-0.3%; +1.7%] (no difference)
startup:petclinic:iast:Agent 17.04 s 16.93 s [-0.3%; +1.6%] (no difference)
startup:petclinic:profiling:Agent 16.06 s 16.67 s [-9.2%; +1.8%] (unstable)
startup:petclinic:sca:Agent 17.04 s 16.80 s [+0.6%; +2.3%] (maybe worse)
startup:petclinic:tracing:Agent 16.11 s 16.16 s [-1.3%; +0.7%] (no difference)

Commit: 4c83a5c3 · 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 changed the title Extract TagMap's bucket mechanics into HashSupport Extract TagMap's bucket mechanics into HashSupport (dense store - part 4) Oct 23, 2026
@bric3
bric3 added this pull request to stack #13019 October 23, 2026 16:02

This branch has not been deployed

No deployments
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 tag: no release notes Changes to exclude from release notes type: refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant