Skip to content

perf(octane): skip unnecessary host prop sorts - #858

Merged
trueadm merged 1 commit into
mainfrom
fix/remove-needless-work
Aug 26, 2026
Merged

trueadm merged 1 commit into
mainfrom
fix/remove-needless-work

Conversation

@jonkwheeler

@jonkwheeler jonkwheeler commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • skip sorting resolved client and server host props when their Map insertion order is already the required authored order
  • retain the sort when a later raw alias (for example htmlFor / for) replaces an earlier normalized identity
  • add server regression coverage for alias winner serialization and coercion order
  • add an octane patch changeset

Why

Every spread-bearing host render copied normalized props into an array and sorted it, even though ordinary props have no normalized collisions and JavaScript Map insertion 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 normalized Map entry.

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.

Resolved attributes Baseline Candidate Change
8 1.704 ms / 1k 1.601 ms / 1k -6.0%
32 6.936 ms / 1k 6.543 ms / 1k -5.7%
128 28.333 ms / 1k 27.617 ms / 1k -2.5%
32 + forced alias collision 8.123 ms / 1k 8.093 ms / 1k -0.4%

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 sync
  • CI=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.md
  • CI=true pnpm exec tsrx-tsc --noEmit -p packages/octane/tsconfig.json
  • CI=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)
  • regression test was observed failing in both octane and octane-prod when the alias-order sort was deliberately removed

Risk

Low. The existing ordering array and downstream client/SSR behavior remain unchanged. A local boolean only skips Array#sort when no winning normalized collision occurred; any winning alias collision preserves the old sort path.

Provenance

  • An agent produced this diff (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 firstOrder after building the resolved Map. A needsWinningOrderSort flag turns sorting on only when a later raw alias (e.g. for after htmlFor) 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 lastOrder beats the previous winner, instead of skipping updates inside a single conditional branch.

A server conformance test asserts alias winner serialization and coercion order (id before the winning for value) for compiled JSX with htmlFor / for collisions.

Reviewed by Cursor Bugbot for commit 0ef9d56. Bugbot is set up for automated code reviews on this repo. Configure here.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work labels Aug 26, 2026
@jonkwheeler
jonkwheeler marked this pull request as ready for review August 26, 2026 08:25
@trueadm
trueadm merged commit d3dbd78 into main Aug 26, 2026
50 checks passed
@trueadm
trueadm deleted the fix/remove-needless-work branch August 26, 2026 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants