Repository navigation
perf: install event and store commit drains when used - #1969
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)
6 other measured values are unchanged. Public-import reachability bundles (bytes)
36 other measured values are unchanged. |
|
Good to go. Both drains are installed before any entry can reach their queues, and the sibling-PR conflicts are append-only. Correctness
Merge note: the conflicts with #1963, #1964, #1966 and #1970 all sit at the same three anchors in Verified:
|
…mmit-hook-owner # Conflicts: # packages/octane/tests/optional-driver-bundle.test.ts
…mmit-hook-owner # Conflicts: # packages/octane/tests/optional-driver-bundle.test.ts
Summary
Let apps that do not use
useEffectEventoruseSyncExternalStoreomit the corresponding commit drains. Each hook installs its existing drain when it first creates a cell. Queue ownership, capture/replay, call positions and both drain implementations are unchanged.The runtime change adds two module bindings and two assignments in existing first-cell branches. It adds no per-update guard, call, allocation, record field or public API. A patch changeset is included.
Validation
Signed
01dcfba0fintegrates main64c33de2f; GitHub reports it mergeable and current-head CI passes. The final integration passes 32 focused dev/prod executions, formatting and sync, with unchanged production hashes during validation and independent source review. An additional 65 targeted incoming-main regression executions pass on this branch using the repository’s dev/prod, signal and profiling projects. The earlier performance measurements retain their stated source and limitations.pnpm format:check(repository-wide; scoped formatting passed)pnpm typecheck(repository-wide; both changed TypeScript files passed)pnpm test(repository-wide; left to CI)pnpm sync; generated source unchanged.check-staged-domand scopedperf-review-scanpass; the scan reports no candidates. Both original drain bodies are unchanged.4cc2a1: Oxc rows 32,140→31,901 (−239 B), JSX 54,702→54,452 (−250 B), Todo −227 B, chat −225 B and weather −239 B. Ordinary esbuild rows 37,614→37,408 (−206 B), JSX 65,062→64,793 (−269 B).perf-review:runtime.ts:11356/11386remain hot commit calls;runtime.ts:16056/16151add only first-cell assignments. Shapes, DOM operations, scheduling and queue records are unchanged. Ordinary and complete owning deterministic work are equal. Both steady owning timings show no detected slowdown; first-use and identical-control limitations are disclosed below. Independent source and evidence review found no must-fix issue; all timing controls and uncertainty are retained.concise-code: runtime +8/−2 lines, tests +88/−2, one release changeset; no module or export added. Reuses the existingnoopand queue consumers. A capability object, consumer guards, or an extra action-drain gate add machinery without earning this change's scope.Risk / follow-ups
CI recorded JSX clear +0.78% (nominal 95% CI +0.22–1.48%) in one paired browser run; retained as an unconfirmed timing difference. No slowdown was detected in the independently grouped owning workloads; no universal parity claim.
Feature-retaining controls pay small gzip overhead: +20 B in the canonical bindings app, +69 B in the canonical full-framework ceiling, and +69/+12 B in the Oxc/esbuild full-API IIFE controls. The event first-owned-commit interval is broad: 1.00449[0.96684,1.07692]; store 0.99683[0.97371,1.02649]. The store identical-code control is positive, 1.00843[1.00117,1.02466], so it indicates measurement variation and is not subtracted from the candidate. This does not establish tight cold-path equivalence.
Phase profiling saw post-paint transport cross CDP capture boundaries. Complete-flow work includes every call through cleanup and a fixed foreground 300ms delivery observation plus 50ms with no asset calls; it is not a universal scheduler-quiescence claim. Original phase failures are preserved, including one earlier unminified four-call discrepancy without historical function attribution.
The adjacent native staged-publication suite is not direct proof of first activation from a native replay. Original queue/capture bodies and producer ownership are preserved; late activation is tested in fresh production realms.
Provenance
agent-authored)Codex task, implementation subtask
retention_audit; hostcom-79386.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Low Risk
Small runtime wiring change with existing drain bodies unchanged; risk is mainly missing late activation if first-cell install were wrong, which new bundle and behavioral tests cover.
Overview
Lazy-installs Effect Event and external-store commit drains so production bundles that never use
useEffectEventoruseSyncExternalStorecan drop the drain implementations.The runtime adds module bindings
drainEffectEventUpdatesanddrainStoreSyncsthat default tonoop; the real logic moves todrainQueuedEffectEventUpdatesanddrainQueuedStoreSyncs, which are wired on first cell creation in each hook. Commit still calls the same indirection—no new per-update guards or API changes. A patch changeset documents the tree-shake win.Bundle tests treat those queued drain declarations like other optional commit code: plain apps must omit them; apps that mount the hooks after a plain root must retain them and keep commit semantics (stable effect events, store tearing checks).
Reviewed by Cursor Bugbot for commit 01dcfba. Bugbot is set up for automated code reviews on this repo. Configure here.