Repository navigation
perf(octane): skip unnecessary host prop sorts - #858
Merged
Merged
Conversation
jonkwheeler
marked this pull request as ready for review
August 26, 2026 08:25
9 of 10 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
Mapinsertion order is already the required authored orderhtmlFor/for) replaces an earlier normalized identityoctanepatch changesetWhy
Every spread-bearing host render copied normalized props into an array and sorted it, even though ordinary props have no normalized collisions and JavaScript
Mapinsertion order already matches their first-authored order. Sorting is only required in the uncommon case where a later raw alias wins without moving the existing normalizedMapentry.This is separate from the recent form-diagnostic, stream-boundary, route-metadata, hydration-template, behavior-queue, deopt-list, and compiler-name performance work.
Performance
Production SSR bundles were measured with the same warmed, adaptive microharness, 9 samples per process, in alternating baseline/candidate process order. The harness renders spread-bearing hosts 1,000 times per measurement and verifies identical serialized bytes and attribute counts.
The forced-alias case is the negative control: it still takes the sort branch and stays effectively flat. Bundle impact is +32 minified bytes in each production bundle (+17 gzip client, +16 gzip server).
Validation
CI=true pnpm syncCI=true pnpm format:files:check packages/octane/src/runtime.ts packages/octane/src/runtime.server.ts packages/octane/tests/conformance/server-input-spread-cascade.test.ts .changeset/skip-ordinary-prop-sorts.mdCI=true pnpm exec tsrx-tsc --noEmit -p packages/octane/tsconfig.jsonCI=true pnpm exec vitest run packages/octane/tests/conformance/client-host-source-aggregation.test.ts packages/octane/tests/conformance/server-input-spread-cascade.test.ts --reporter=dot(4 files, 90 tests)octaneandoctane-prodwhen the alias-order sort was deliberately removedRisk
Low. The existing ordering array and downstream client/SSR behavior remain unchanged. A local boolean only skips
Array#sortwhen no winning normalized collision occurred; any winning alias collision preserves the old sort path.Provenance
agent-authored)Note
Low Risk
Behavior is unchanged when alias collisions occur (sort still runs); the change only avoids sort on the common no-collision path in spread-heavy host rendering.
Overview
Client and server host prop merging no longer always sorts normalized props by
firstOrderafter building the resolvedMap. AneedsWinningOrderSortflag turns sorting on only when a later raw alias (e.g.forafterhtmlFor) wins over an existing normalized identity without moving that entry—otherwise iteration order is used as-is.The merge loop now always writes the winning prop when
lastOrderbeats the previous winner, instead of skipping updates inside a single conditional branch.A server conformance test asserts alias winner serialization and coercion order (
idbefore the winningforvalue) for compiled JSX withhtmlFor/forcollisions.Reviewed by Cursor Bugbot for commit 0ef9d56. Bugbot is set up for automated code reviews on this repo. Configure here.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.