Skip to content

Commit 6d24aeb

Browse files
dougqhclaude
andcommitted
Scrub SpanPrototype references from the SizingHint layer
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>
1 parent b294856 commit 6d24aeb

3 files changed

Lines changed: 17 additions & 21 deletions

File tree

dd-trace-core/src/main/java/datadog/trace/core/DDSpanContext.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,10 @@ public class DDSpanContext
139139
*/
140140
private final TagMap unsafeTags;
141141

142-
// Per-type sizing hint (e.g. a SpanPrototype) this span was created from, if any. Held so the
143-
// span
144-
// can feed its final dense-store size back on finish (recordSize) -- the self-tuning loop that
145-
// lets
146-
// the reused hint converge to the type's real known-tag high-water mark. Null when unsized.
142+
// Per-operation sizing hint (from SizingHintTable, keyed by operation name) this span was sized
143+
// from, if any. Held so the span can feed its final dense-store size back on finish (recordSize)
144+
// -- the self-tuning loop that lets the reused hint converge to the operation's real known-tag
145+
// high-water mark. Null when unsized.
147146
private final SizingHint sizingHint;
148147

149148
/** The service name is required, otherwise the span are dropped by the agent */
@@ -977,10 +976,9 @@ public void setTag(final String tag, final String value) {
977976
}
978977

979978
/**
980-
* Feeds this span's final dense-store size back into the sizing hint it was created from (if
981-
* any). Called once at span finish; lets a reused hint (e.g. a per-type SpanPrototype) self-tune
982-
* to the type's observed known-tag high-water mark, so subsequent spans of the type are sized
983-
* correctly.
979+
* Feeds this span's final dense-store size back into the sizingHint it was created from (if any).
980+
* Called once at span finish; lets a reused hint self-tune to the operation's observed known-tag
981+
* high-water mark, so subsequent spans of the operation are sized correctly.
984982
*/
985983
void recordDenseSize() {
986984
if (sizingHint != null) {

internal-api/src/jmh/java/datadog/trace/api/DenseStoreAllocBenchmark.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ public class DenseStoreAllocBenchmark {
9090

9191
private String[] keys;
9292
private String[] values;
93-
// Per-type sizing hint seeded to this scenario's known-tag count -- what a SpanPrototype
93+
// Per-operation sizing hint seeded to this scenario's known-tag count -- what SizingHintTable
9494
// supplies.
95-
private SizingHint prototype;
95+
private SizingHint sizingHint;
9696

9797
@Setup(Level.Trial)
9898
public void setup() {
@@ -111,8 +111,8 @@ public void setup() {
111111
this.keys[i] = i < knownCount ? KNOWN[i] : "custom.tag." + i;
112112
this.values[i] = "value-" + i;
113113
}
114-
// Size the dense store to the known-tag count (the "end state" per-type sizing).
115-
this.prototype = new SizingHint("bench", 0, Math.max(knownCount, 1));
114+
// Size the dense store to the known-tag count (the "end state" per-operation sizing).
115+
this.sizingHint = new SizingHint("bench", 0, Math.max(knownCount, 1));
116116
}
117117

118118
/** Current: generic default dense capacity (KNOWN_INIT_CAP=12) -- over-provisions small types. */
@@ -125,12 +125,10 @@ public TagMap buildMap() {
125125
return m;
126126
}
127127

128-
/**
129-
* End state: dense store sized per-type via a SpanPrototype (SizingHint) -- no over-provision.
130-
*/
128+
/** End state: dense store sized per-operation via a SizingHint -- no over-provision. */
131129
@Benchmark
132130
public TagMap buildMapSized() {
133-
TagMap m = TagMap.create(prototype);
131+
TagMap m = TagMap.create(sizingHint);
134132
for (int i = 0; i < tagCount; i++) {
135133
m.set(keys[i], values[i]);
136134
}

internal-api/src/main/java/datadog/trace/api/TagMap.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,10 +1071,10 @@ public EntryChange next() {
10711071
* <ul>
10721072
* <li><b>Tier 1 — group mask:</b> one bit per declaration group ({@code 1L << group-decl}). A
10731073
* clear group bit proves EVERY tag of that group is absent, so seeding a fresh group (e.g.
1074-
* a {@code SpanPrototype} bulk insert) skips the scan for the whole group — the bulk-insert
1075-
* payoff. Disjoint groups across two maps ({@code (a.knownGroupMask & b.knownGroupMask) ==
1076-
* 0}) prove nothing shadows across them, which the read-through shadow check exploits (see
1077-
* {@link #parentDenseVisible}).
1074+
* a bulk insert) skips the scan for the whole group — the bulk-insert payoff. Disjoint
1075+
* groups across two maps ({@code (a.knownGroupMask & b.knownGroupMask) == 0}) prove nothing
1076+
* shadows across them, which the read-through shadow check exploits (see {@link
1077+
* #parentDenseVisible}).
10781078
* <li><b>Tier 2 — field bloom:</b> when the group bit clashes, fall back to one shared word
10791079
* over {@code field-decl & 63}. A clear field bit still proves absence; a clash falls
10801080
* through to the authoritative scan.

0 commit comments

Comments
 (0)