Repository navigation
perf(octane): share nearest-provider records across direct context reads - #2084
domgan-oai wants to merge 4 commits into
Conversation
Benchmark report
Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)
13 other measured values are unchanged. Public-import reachability bundles (bytes)
40 other measured values are unchanged. |
trueadm
left a comment
There was a problem hiding this comment.
Thanks. CI is green and the provider work controls in the body match. My concern is the same as on #2083: next is size-focused, and the benchmark report (run 38741497516) shows bytes going up with no measured speed-up.
- Size (gzip):
- js-framework tsrx +40 B (fw +39);
- todo +45, chat +31, weather +16;
- bindings +67.
- Speed: every js-framework operation is within noise.
Could you add a benchmark that shows what the shared records save? The memo-wall provider-scope bench from #2073 could work, for example, measuring allocations or time for N direct readers under one provider, before and after. Without that, the trade is bytes on every app for a saving we can't see.
This change is also larger than it looks. It touches cached-context restamping, deferred-hydration activation records and DevTools unwrapping. If you keep it:
- add a hydration test where a deferred island's direct reader sees a provider value change before and after activation;
- add a check that DevTools still shows the raw provider value.
Reviewed with Claude Code
|
@trueadm Following up on your review: I ran the existing memo-wall workload on current head The requested deferred-reader regression and raw DevTools-value regression are in the current head. The tradeoff remains real: the current benchmark reports +43 B TSRX and +119 B JSX full-JavaScript gzip, with all 64 work counters unchanged and no broad timing verdict. The full targeted methodology and results are in the PR description; current-head CI is green. |
Summary
Reading from a nearest provider previously stamped its own aggregate, then allocated a reader Map and a new record for the same value on every render. Record the context at ancestor frontiers, share one stable owner/value/version record from the provider, and inline the first direct read before spilling to a Map. Explicitly stamp hosted/coarse readers so sibling invalidation remains correct.
Adapt cached-context restamping and deferred hydration to next's current ABI: The #2090 port keeps context, component slots, hydration boundary, block, render and types in their owning modules; runtime.ts stays next's unmodified facade. SSR values stay raw, activation wraps records owned by the activation block, and DevTools unwraps for display. Extracted from #2036; applies independently to
next.Validation
Targeted provider measurement
Measured the current post-#2090 implementation
ae2367930against its actual merge baseee7d52073. The checked-inbenchmarks/memo-wall/octane-tsrxworkload was built separately for each revision with identical fixture source hashes, the same production Oxc toolchain, and source maps checked against the selected runtime. Wall A uses a compiled list; wall B uses returned component descriptors. Each wall has 1,000 direct context readers. Real Chromium, two warmup pairs and 18 alternating measurement pairs, with 10 provider changes per sample:The update-plus-unchanged-sibling-bail case was also measured in both directions for each shape. For all 12 cases, both revisions performed exactly 10,000 owning leaf renders and zero sibling, row, or inner renders in every sample; live values and original host identity were checked after every timed sample. In the same-context sibling-bail cases, paired timing was −15.1% and −21.8%. The full production JavaScript gzip in the three targeted fixtures grew +10/+10/+39 B (raw +132 B each). The independent current-head PR benchmark's broader app costs are below.
A matched baseline/baseline control included zero in 9/12 intervals. Three controls showed asymmetry: distinct-context A −2.5%, same-context sibling B −4.9%, and separate-root A +7.0%. The direction of the provider-update improvement is consistent across the measured shapes, but individual percentages are not wholly attributable to this change. This measures synchronous update time, not allocation bytes or end-user latency.
Size / risk
Current PR bench, next ee7d520 → merge e5e9eb2 of ae23679: full JavaScript gzip TSRX 31,333 → 31,376 B (+43), JSX 55,100 → 55,219 B (+119). Threadline Oxc 52,860 → 52,880 B (+20) / esbuild 59,796 → 59,821 B (+25). Pagecraft Oxc 171,281 → 171,318 B (+37) / esbuild 186,569 → 186,597 B (+28). Raw deltas are +132/+424 B in TSRX/JSX and +79/+71 B Threadline, +132/+125 B Pagecraft. All 64 work counters unchanged and all 20 paired js-framework timings within noise. Across 41 reachability probes, gzip deltas range −6 to +137 B; 13 are byte-identical, including capture-only, SSR, split-shell-signals and both behavior roots. These are small but real context-capable bundle costs for shared direct reads.
Provenance
agent-authored)Implementation: Codex task · host
com-79386.Need help on this PR? Tag
@codesmith-botwith what you need.Note
Medium Risk
Touches core context versioning, memo/implicit bailouts, compiler cache restamping, and deferred hydration—areas where subtle stale-value bugs are possible, though behavior is heavily regression-tested.
Overview
Context providers and consumers now store
ProvidedContextrecords (value,owner,version) in$$ctxValuesinstead of raw values.provideContextand the read path stamp and returnprovided.value, while memo/bailout logic compares against the shared record.Direct reads reuse the nearest provider’s record when the read is verifiable (sibling-provider case): the first direct dependency can live inline on
$$ctxDirectas that record instead of always allocating aMapand a duplicate{ owner, value, version }. Hosted/coarse/mixed reads stay conservative;recordLocalContextValueis removed in favor ofrecordContextDependencyduringreadContextFrom.Downstream ABI tweaks: render clears
$$ctxDirectfor Map vs single-record shapes; cached-context restamping and deferred hydration build or compareProvidedContextwhere activation needs owner metadata; DevTools previewsvalue.valueso objects with their ownvaluefield display correctly.Tests cover outer provider changes before/after a deferred hydrate reader and DevTools context preview for nested
{ value, owner }payloads.Reviewed by Cursor Bugbot for commit ae23679. Bugbot is set up for automated code reviews on this repo. Configure here.