Thread SpanPrototype through span construction (parked until dense store)#11834
Draft
dougqh wants to merge 1 commit into
Draft
Thread SpanPrototype through span construction (parked until dense store)#11834dougqh wants to merge 1 commit into
dougqh wants to merge 1 commit into
Conversation
…bing) Threads a spanPrototype through the span builder exactly like tagLedger — field + startImpl + both startSpan overloads + buildSpan + buildSpanContext + reset — and applies it at buildSpanContext right after defaultSpanTags (before the per-span ledger, so per-span tags override the prototype's constants). Adds CoreSpanBuilder.withSpanPrototype(...) as the setter. Additive: defaults to SpanPrototype.NONE at every site, so the applied branch is skipped and every existing span-creation path is byte-for-byte unchanged. CoreSpanBuilderTest (25) + CoreTracerTest2 (15) green. Next: public startSpan/buildSpan(SpanPrototype, ...) entry points + the old-vs-new SpanStartBenchmark (which exercises the seeding end-to-end). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft — PARKED. Stacked on #11828. Do not merge before the dense store.
Increment 2a of the SpanPrototype work: threads a
spanPrototypethroughCoreSpanBuilder(mirroringtagLedger— field,startImpl, bothstartSpanoverloads,buildSpan,buildSpanContext,reset) and applies it atbuildSpanContextright afterdefaultSpanTags(before the per-span ledger, so per-span tags override the prototype's constants). AddsCoreSpanBuilder.withSpanPrototype(...).Why parked
The construction-seed's payoff is a copy-down, which only beats per-span N-
setwhen the copy is cheap. On today's bucketedOptimizedTagMapit isn't — the per-mechanism micro (on #11828) showedcopy()of a 4-entry map losing to 4set(cachedEntry)(≈295M/243M vs 417M ops/s), with identical 104 B/op across all arms. The win is dense-store-gated: a contiguous positional layout makes copy-down anarraycopy, and drops the alloc.So this lands with/after the dense store, where touching the critical span-creation path arrives with a demonstrable win rather than a flat change. Because SpanPrototype rides the existing
TagMap.copy/setAllTagsAPI (not dense internals), the wiring auto-cashes-in when the dense store lands — no surface change, no penalty to holding.Safety
Additive:
SpanPrototype.NONEdefault at every threaded site → the applied branch is skipped and every existing span-creation path is byte-for-byte unchanged.CoreSpanBuilderTest(25) +CoreTracerTest2(15) green.Remaining (when unparked)
startSpan/buildSpan(SpanPrototype, …)entry points (additive overloads, delegate existing →NONE).SpanStartBenchmark({startSpan, buildSpan}×{old afterStart, new prototype}) to characterize the dispatch-level delta on the dense store.🤖 Generated with Claude Code