Repository navigation
perf: index hoisted client capture values - #992
Merged
domgan-oai merged 1 commit intoSep 8, 2026
Merged
Conversation
domgan-oai
marked this pull request as ready for review
September 8, 2026 13:00
Closed
68 of 84 tasks
6 of 8 tasks
14 of 21 tasks
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
__extraarray.Why
The compiler currently emits array destructuring on every keyed item and control-flow arm invocation. Even an elision-only arm requests an iterator and advances it before optimized JIT tiers can remove that work. The runtime already supplies a regular array, and another compiler fast path reads it by index.
Changes
hoistBodyHelperdestructuring AST with direct indexed bindings for each helper's own captures. Keep union-only names unbound so local shadowing remains valid, and preserve the existing tuple indices, including special keyed-item ordering.@empty, and refill.octanepatch changeset. The separate server capture path is unchanged.Validation
node --checkfor the compiler, andgit diff --check.0dd952979b441b10bd0e2ea8c5779c11583770ec. Both changed test files ran and passed inoctaneandoctane-prod(nested directives: 3 tests per project; value-position directives: 85 per project). Typecheck and browser integration passed.27898 / 25698 = 1.0856versus 1.06, and CSS-module client minified2341 / 2743 = 0.8534versus 0.84. An identical-workflow baseline run on merged main failed the same two guards; this PR increased aggregate compiled bytes by +340 raw, +109 minified, and +75 gzip versus main (27823→27898gzip). The CSS-module sentinel was byte-identical. A separate, unshipped compact-binding trial recovered only 15 of those gzip bytes; the shipped code is the tested PR head. The full quick Bench run was canceled after more than 60 minutes. It uploaded partial results for 78/92 suites; suite 79 (tsrx-hydrate-module-slicing) logged no progress for about 26 minutes, so no full ratio summary exists. Several earlier suites had unrelated correctness or size failures. The paired targeted runs above provide the deterministic codegen-size evidence. Fork-only workflow setup changes for runner selection and local benchmark links did not change package source, benchmark scripts, or the lockfile.@tsrx/[email protected]dependency is unavailable locally; frozen install andpnpm synccould not complete through the configured registry. The automatic approval review rejected a direct public-registry fetch as a bypass of that registry. CI validated the pinned compiler, compiled output, and public fixture behavior.Risk / follow-ups
The array ABI remains internal and always receives arrays from the runtime. A user-modified
Array.prototype[Symbol.iterator]would no longer be invoked by these generated capture reads. Isolated fully populated helpers can gain minified bytes while sparse/elision-only helpers shrink, so the pinned codegen-size and benchmark ratio gates matter. No broad runtime speed claim is made from the synthetic proxy.Refs #981. Follows merged #991.
Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Touches hot-path client compiler output for every hoisted template arm, but the
__extraABI and runtime contract are unchanged and behavior is locked down with new fixture coverage.Overview
Client codegen for module-scoped construct helpers (
@if/@else,@foritem/@empty, etc.) no longer opens__extrawith array destructuring. Each helper now emitsconst name = __extra[i]only for captures that arm actually uses, keeping the same union tuple indices (including keyed@forreordering) so sparse arms and local shadowing stay correct.Server capture lowering is unchanged. Tests now expect indexed client bindings, and
SparseCaptureFeedplus a mount test cover sparse nested arms, keyed reorder/identity, branch flips,@empty, and refill.Patch changeset for
octane.Reviewed by Cursor Bugbot for commit 0dd9529. Bugbot is set up for automated code reviews on this repo. Configure here.