Repository navigation
perf(octane): drop unused ref consumers from bundles - #1970
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)
9 other measured values are unchanged. Public-import reachability bundles (bytes)
36 other measured values are unchanged. |
|
Good to go, with two optional nits. Every ref producer installs its consumers before it publishes, so a
Merge note: the conflicts with #1963, #1964, #1966 and #1969 are append-only in Verified:
|
|
Strengthened the test in a72a7f2: both reveal and discard now assert that the cleanup has already run when Suspense hides the subtree. All four development/production cases pass. Removing the hide-detach installer makes both discard cases fail at that new assertion; restoring it passes both again. Runtime source is unchanged. Sync and scoped formatting pass; the signed base integration is 7b12dbf, with all 30 current-head checks passing. |
Summary
Applications whose compiled runtime does not use refs can omit ref commit drains and subtree ref collection. The existing attach queue installs its drain, collector and detach suppression before publishing its first entry; the detach queue installs its drain before its existing early returns. Installation is monotonic. All four implementation bodies, public ref helpers, spread/deopt/Fragment behavior and queue ordering remain unchanged.
Current compiled spreads snapshot props and queue actual ref publication before publishing their resolved record, so they need no new check. The change adds no per-node fields, records, scheduling operations or calls. Three existing benchmark source/name oracles recognize the renamed implementations while preserving their metric keys and comparisons with older revisions.
Matched complete-production-JavaScript gzip bytes against
4cc2a1edusing Node 24.20.0:The rows reduction is 2,219 raw/507 Brotli bytes with Oxc and 2,394 raw/572 Brotli bytes with esbuild. Full-API raw growth is 92/98 bytes. Feature-retaining bundle growth is included above; these are measured totals, not sums of independent reductions.
Validation
pnpm format:check— scoped authored-file formatting and current-head CI lint/format checks pass.pnpm typecheck— runtime/index and the changed test program pass scoped typechecks with no diagnostics; full current-head CI typechecks also pass.pnpm test— all four Node 24 test shards and the aggregate gate pass on current head. React parity, Chromium integration, package validation and example builds also pass.perf-review: zero mechanical candidates and no unresolved source finding.queueRefAttach/queueRefDetach(runtime.ts:10213,10256) run per queued attachment/detachment; their identity guards install stable consumers once. The four module bindings and callback-preserving default (runtime.ts:432,437) add no hot-record fields, per-call allocation, DOM work or scheduling. Existing consumer calls stay in place; the first-use and steady-work evidence is below.concise-code: source/runtime +23 −4; no new module, public export, type, option or record field. The only new file is the package changeset. Existing queue producers and noop identity checks provide ownership; an unnecessary spread guard was removed after tracing snapshot publication. A return-preserving default is needed for suppression's existing callback result. No separate activation flag, registry or reference count. Measured bytes and feature-retaining growth are listed above.pnpm sync— passed; no generated diff, and all 255 measured package files plus the final test remain hash-identical.Risk / follow-ups
The prespecified owning timings use Node 24.20.0 and bundled Chromium 149.0.7827.55, with 16 independent fresh browser-process groups per candidate and identical-baseline cohort, balanced creation/execution order, 10 warmup and 12 retained pairs per group. Every realm first executes 1,001 actual no-ref layout commits. All 64 groups, 1,408 paired windows, 38,016 steady/warm bursts and 128 first-use receipts are retained; source/artifact, semantic, cleanup and browser-error guards pass.
No slowdown was detected in these prespecified fresh-group owning workloads; the primary intervals still permit +1.04% and +0.40%. Each sample sums the original internal run durations across 16 or 11 complete fresh prepare/run/verify/cleanup bursts, rather than one continuous window. Retained sums range 24.01–29.68 ms and 26.23–33.47 ms. Primary bootstrap inputs are group arithmetic means.
First preparation and first run are separate, less precise observations; preparation includes the original model construction and assertions. Their intervals all include 1, but replacement's first-run ratio is 1.0225 [0.9974, 1.0404]. Identical-code controls show execution-order effects, which remain in the reported descriptive partitions. These results do not establish a speedup or universal/tail latency. The final independent source and evidence audits are clean; current-head CI remains separate.
The scope-less public attach/spread helpers do not create subtree manifests, and their behavior is unchanged.
Current head
564d5b723has green current-head CI, no pending or failed checks, no open review threads, and is ready for review and conflict-free. The 19 earlier draft-skipped checks are not counted as validation. The independent local performance evidence and its limits below remain separate from green CI.Current-head CI benchmark report confirms the rows reduction above and all 64 unchanged work counters. Its synthetic merge
5dcba83e4has exactly the same Git tree as published head564d5b723. Additional complete-bundle gzip changes are Todo −636 B, chat −637 B, weather +47 B and bindings +26 B; public-import controls range from savings in ref-free roots/hooks to small growth in feature-retaining bindings and hydration.CI labels all 20 timings within its ±3% verdict threshold, but three 95% intervals are strictly positive: TSRX clear +2.5% [+0.1%, +4.7%], JSX update +2.0% [+0.6%, +2.8%], and JSX large-list selection +5.3% [+0.6%, +7.9%]. Those observations remain recorded. Unchanged work and the local owning timings do not establish that these distinct operations cannot regress. A single prespecified follow-up addressed only the strongest signal, JSX large-list selection; clear and update remain separate, unattributed CI observations.
The large-list selection follow-up reuses the exact ordinary esbuild artifacts and canonical 10,000-row selection operation. It retains 16 independent fresh browser-process groups per actual and identical-baseline cohort, each with 30 warmup and 10 retained pairs, balanced order and group arithmetic means as primary inputs. All 32 groups and 1,280 pairs, paired-input/row-identity/selection gates, 843 source/config input hashes and eight artifact hashes pass. Independent review reproduced the statistics and provenance.
No slowdown was detected in this local fresh-selection cohort: candidate/baseline 0.9966 [0.9856, 1.0134], identical-code control 1.0045 [0.9942, 1.0209]. All creation/execution-order intervals include 1. The original CI +5.3% observation was not reproduced under this host/history; it is not proved spurious. The candidate interval still permits +1.34%. Batches use 20–28 real alternating selections and retain 25.85–45.36 ms windows; 40 ms was a calibration target, not a minimum. This does not replay the full preceding CI operation history or establish universal/tail performance.
This is an incremental bundle reduction. Current-head CI and independent source/evidence review are complete for this scope, with the cold-use, order and remaining CI timing limitations disclosed above. No merge is requested.
Provenance
agent-authored)Codex task · implementation subtask
duplication_audit· hostcom-79386.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Touches core commit-phase ref ordering and Suspense/Activity subtree ref paths, but semantics are intended to be identical after first-queue installation; risk is mainly missed lazy-install edge cases in spread or deferred ref publication.
Overview
Lazy-installs ref commit plumbing so apps that never queue refs can drop ref drain and subtree-collection code from production bundles (~650B on ref-heavy row fixtures per the PR).
The runtime now starts
drainRefAttaches,drainRefDetaches,detachSubtreeRefs, andwithRefDetachSuppressionas no-ops (or a pass-through for suppression). The firstqueueRefAttachwires the real attach drain, subtree detach walker, and suppression helper; the firstqueueRefDetachwires the detach drain. Implementation bodies are renamed (drainQueuedRefAttaches, etc.) but behavior at commit is unchanged.Benchmarks map the new internal names back to existing metric keys. New bundle tests assert ref helpers are absent without refs, fully retained when refs activate late, and subtree helpers stay for Suspense spread-ref hide/reveal.
Reviewed by Cursor Bugbot for commit 7b12dbf. Bugbot is set up for automated code reviews on this repo. Configure here.