Skip to content

Add per-operation self-tuning dense-store sizing (SizingHint)#12056

Draft
dougqh wants to merge 4 commits into
dougqh/generator-v2from
dougqh/sizing-hint
Draft

Add per-operation self-tuning dense-store sizing (SizingHint)#12056
dougqh wants to merge 4 commits into
dougqh/generator-v2from
dougqh/sizing-hint

Conversation

@dougqh

@dougqh dougqh commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

What

Sizes each span's dense TagMap store from a per-operation sizing hint instead of a generic default, then feeds the actual known-tag count back on span finish so the hint converges to that operation's real high-water mark. Over-provisioning shrinks toward the operation's true shape without any hand-tuned per-type tables.

This is the SizingHint layer of the dense-store stack, sitting between the generator (dougqh/generator-v2) and the id-keyed TagMap.set(long) work (dougqh/tag-id-api, #11901).

How

  • FlatHashtable — open-addressed find-or-create over self-contained entries; static-polymorphism via a concrete-typed Helper singleton so the JIT devirtualizes/inlines hash/matches/create per call site. Single-reference publish → torn-free under racy access.
  • SizingHint / SizingHelper — opaque per-operation hint (label + cached hash + tuned size) and its String-key helper.
  • SizingHintTable — process-wide, pure-static two-lane (entry vs child span) registry keyed by operation name. Fixed-capacity and deliberately lock-free/racy: a lost update or double-mint only mis-sizes an array (over/under-provision) for a span or two — it never corrupts tag data.
  • WiringCoreTracer.buildSpanContext resolves the hint by operation name + entry-ness and hands it to DDSpanContext, which sizes its TagMap from it and records the final size back via DDSpan.finishAndAddToTrace.

Testing

  • FlatHashtableTest, SizingHintTableTest (incl. the self-tuning recordSize loop and content-keying so a UTF8BytesString operation name resolves to the same hint as its String form).
  • Benchmarks: FlatHashtableBenchmark; a buildMapSized arm in DenseStoreAllocBenchmark.
  • spotlessJavaCheck, :internal-api:spotbugsMain, :dd-trace-core:spotbugsMain all green.

Notes

  • No behavior change to tag semantics — this only sizes the backing store.
  • The three delegating test-only DDSpanContext ctors are marked @Deprecated @VisibleForTesting to steer new code to the full ctor.

🤖 Generated with Claude Code

dougqh and others added 4 commits July 23, 2026 08:59
Sizes each span's dense TagMap store from a per-operation hint instead of a
generic default, then feeds the actual known-tag count back on finish so the
hint converges to the operation's real high-water mark.

- FlatHashtable: open-addressed find-or-create over self-contained entries;
  static-polymorphism via a concrete-typed Helper singleton so the JIT
  devirtualizes/inlines hash/matches/create per call site.
- SizingHint / SizingHelper: opaque per-operation hint + its String-key helper.
- SizingHintTable: process-wide, pure-static two-lane (entry vs child) registry
  keyed by operation name; fixed-capacity + deliberately lock-free/racy (a lost
  update or double-mint only mis-sizes an array, never corrupts tag data).
- CoreTracer.buildSpanContext resolves the hint by operationName + entry-ness and
  hands it to DDSpanContext, which sizes its TagMap and records the size back via
  DDSpan.finishAndAddToTrace.
- Tests: FlatHashtableTest, SizingHintTableTest (incl. self-tuning + content-keying).
- Benchmarks: FlatHashtableBenchmark; DenseStoreAllocBenchmark buildMapSized arm.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
SpanPrototype and SizingHint converge in a later PR; on this branch the hint is
a SizingHint keyed by operation name (SizingHintTable), so the illustrative
SpanPrototype mentions were misleading. Reword comments and rename the benchmark
field to sizingHint.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signals intent: this delegating overload has no production caller (CoreTracer
uses the full ctor); its ~20 callers are tests/jmh.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The three delegating overloads exist only to spare tests the param churn from
signature changes; none has a production caller. Mark them all @deprecated
(steer new code to the full ctor) and @VisibleForTesting (signal intent).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dougqh dougqh added comp: core Tracer core tag: no release notes Changes to exclude from release notes type: refactoring tag: ai generated Largely based on code generated by an AI or LLM labels Jul 23, 2026
@datadog-datadog-prod-us1-2

This comment has been minimized.

@dd-octo-sts

dd-octo-sts Bot commented Jul 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.97 s 13.96 s [-0.7%; +0.8%] (no difference)
startup:insecure-bank:tracing:Agent 12.97 s 12.95 s [-0.7%; +0.9%] (no difference)
startup:petclinic:appsec:Agent 16.83 s 16.77 s [-0.7%; +1.5%] (no difference)
startup:petclinic:iast:Agent 16.92 s 16.92 s [-0.8%; +0.8%] (no difference)
startup:petclinic:profiling:Agent 16.57 s 16.79 s [-2.6%; +0.1%] (no difference)
startup:petclinic:sca:Agent 16.90 s 16.25 s [-0.4%; +8.4%] (no difference)
startup:petclinic:tracing:Agent 16.13 s 16.00 s [-0.3%; +1.8%] (no difference)

Commit: 956f2c9a · 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.

@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Bits has a CI fix ready

🟢 Investigated · 🟢 Fix prepared · ⚪ Validation skipped · 🟠 Ready

Registered appsec.agentic_onboarding in AppSec configuration and read it with an empty default during Config initialization, so the setting is emitted in configuration telemetry.

Commit fix to this PR


View in Datadog | Reviewed commit 956f2c9 · Any feedback? Reach out in #deveng-pr-agent

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