Repository navigation
perf(octane): tree-shake unused controlled event restoration - #1946
Merged
trueadm merged 3 commits intoOct 9, 2026
Merged
Conversation
trueadm
marked this pull request as ready for review
October 9, 2026 17:41
Contributor
Benchmark report
Compares js-framework: 1k/10k row operations
All 20 timed operations (19 without a verdict)
Work counters (an increase fails this check):
44 other measured values are unchanged. Application bundle size (bytes)
10 other measured values are unchanged. Public-import reachability bundles (bytes)
36 other measured values are unchanged. |
1 task done
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.
Summary
Applications that never mount a controlled input can now tree-shake the controlled-event enqueue and dispatch-finish paths. The first controlled binding installs the existing enqueue and dispatch-finish functions; controlled inputs retain their current behavior even when first mounted during a native event.
This isolates event restoration only. Capture fallback scheduling remains active before the first control is armed, and reads the capability when it runs. Controlled commit drains, autofocus, scheduling, and element/Block/Scope shapes are unchanged. No public API or compiler output changes.
Validation
pnpm format:check: not run repo-wide;node scripts/format-files.mjs --check --on every changed file passes with the pinned formatter.pnpm typecheck: not run repo-wide;node scripts/typecheck-files.mjs -- packages/octane/src/runtime.ts packages/octane/tests/form-action-bundle.test.tspasses with the pinned native TypeScript and admitted content mapper.pnpm test: full suite left to CI.pnpm run sync) passes and produces no generated changes.77571d9, candidate0f667b7: 30 alternating pairs after six warmups, eight valid 512-event bursts per window, Node 24.20.0 and Chromium 149.0.7827.55. Capture paired ratio 0.978 (95% 0.954–0.994; median windows 25.0/24.5 ms), no capture 1.002 (0.976–1.028; 20.2/20.4 ms). Neither indicates a slowdown beyond the repository’s 3% threshold; no speedup claim. Exact call/DOM counts and all semantic checks above also passed against this base.perf-review: scoped diff scan reports no candidates. Event call sites replace existing direct calls with guarded capability calls, with no wrapper calls, allocations per event, DOM operations, or scheduling changes. One driver object is allocated when the first controlled record is created. Work and timing evidence above cover absent and installed capabilities.concise-code: runtime +23/−7; tests +103/−1 and extend the existing production-bundle harness; only new file is the patch changeset. No new exports. A boolean guard was rejected because esbuild would retain concrete function references; the two-method capability places those references at their existing owner. Broader signal-owner extraction was deferred because explicit root owners and late-imported signal authority need a separate design.Current-head PR benchmark report, comparing base
114e3b83dwith PR merge19a35f4fcfor published head14a1d4ef3, on the same CI runner. Framework bytes:Complete-app gzip saves 668 bytes in rows and 771 in weather. TodoMVC grows 49 bytes, chat 61, JSX rows 33, and bindings 35. These are incremental savings, not a 40% reduction. All 20 function-call counters fall by two, with the remaining 44 work counters unchanged. Of 20 timing comparisons, 19 have no verdict and JSX swap is reported faster; none is reported slower.
A separate byte-only composition check over #1942 at
d0fa09f1e94b4f67c8999c67e27a940a096845f5still saves 617 bytes framework gzip in rows and 705 in weather. This confirms the savings are incremental to its optional-driver folding changes; it is not correctness qualification of that other PR.Risk / follow-ups
Provenance
agent-authored)Origin: Codex task, implementation host
com-79386.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Touches core delegated event dispatch and React-style controlled value restoration; incorrect tree-shaking or guard logic could break inputs or leave stale DOM values, though the PR adds targeted bundle and behavioral tests.
Overview
Controlled-input event restoration (
maybeEnqueueRestore/maybeFlushDiscrete) is no longer wired unconditionally into delegated event dispatch. A lazyCONTROLLED_RESTORE_DRIVERis installed the first time a control is armed inarmControlledBase; dispatch paths only enqueue/finish restores when that driver exists, so production bundles that never use controlled bindings can drop the restore graph.Behavior is unchanged once any controlled binding exists: the same functions are registered on the driver, including when a control is first made controlled inside a native listener after capture stops bubbling. Production bundle tests now assert restore helpers are absent from click-only apps, present when
valuebindings are used, and still correct for nested roots and unmount/remount.Reviewed by Cursor Bugbot for commit 14a1d4e. Bugbot is set up for automated code reviews on this repo. Configure here.