Skip to content

perf: avoid host child rest-array forwarding - #1025

Merged
domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/host-component-trampoline-981
Sep 9, 2026
Merged

domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/host-component-trampoline-981

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Forward the three ComponentBody arguments directly through the stable hostComponent child body, preserving its latest target and return value without a rest array.
  • Add compiled callable-child tests for live props, state, DOM identity, ref/effect cleanup on removal, remounts, and returned renderables.
  • Add a production work-count benchmark with equivalent descriptor-child controls.

Why

Issue #981 identifies per-render rest/spread allocation in the host-child trampoline. The body ABI supplies exactly three arguments; a host adapter such as motion.div can forward them directly.

Validation

  • pnpm format:check — scoped formatting passed locally; the CI lint checks passed.
  • pnpm typecheck — the local run reached its final command without diagnostics, but a shell wrapper masked its exit code; the CI typecheck passed.
  • pnpm test — focused tests passed locally; all current-head CI test shards passed.
  • pnpm typecheck:files packages/octane/src/runtime.ts packages/octane/tests/host-component-props.test.ts packages/octane/tests/_fixtures/host-component-children.tsrx
  • pnpm format:files:check on all changed source, tests, benchmark files, and changeset.
  • Host-component tests in dev/prod: 16 passed; a deliberately stale child target fails both new cases in both modes before restoring the implementation.
  • Motion render/rerender and compiled ref-detach tests: 16 passed.
  • node benchmarks/host-component/work.mjs: semantic controls and work counts pass.
  • pnpm sync: no generated changes.

Performance audit

In the same production esbuild + Chromium 149 jitless observer on Node 26.4, rest-parameter executions fall from 128/1,024 to 0 per mount or update with 128/1,024 callable-child hosts, and from 1,536/12,288 to 0 across twelve updates. Host and child call counts, output, DOM identity, nesting, and teardown match; equivalent descriptor-child controls remain at zero. The unminified observer bundle grows 26 bytes. These are deterministic source/interpreter work counts, not a throughput claim.

Risk / follow-ups

The wrapper's receiver, latest child target, three positional arguments, and return value remain intact. A separate baseline root-unmount ref cleanup behavior in this host path was observed during test development; removal/ref cleanup and root-unmount effect cleanup are covered here. The remaining per-render allocation examples in #981 stay open.

Provenance

  • An agent produced this diff (agent-authored)

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


Note

Medium Risk
Touches the hot hostComponent child-reconciliation path in core runtime, though the ABI is unchanged and tests/benchmarks target reconciliation and forwarding semantics.

Overview
Removes per-render rest-argument array allocation in reused host components (e.g. motion.<tag>) by changing the stable child delegator in hostComponent from (...args) => latest(...args) to explicit (props, scope, extra) => latest!(props, scope, extra), while still updating state.latest each render so childSlot keeps a stable body identity.

Adds regression coverage for callable children (returned renderables) and compiled host children (props updates, preserved state/DOM, @if removal, ref/effect cleanup, remounts), plus a production benchmark that bundles the real runtime, asserts semantics/DOM identity, and gates on zero rest parameters in the emitted trampoline (with optional --measure for baseline comparison).

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

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work labels Sep 9, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review September 9, 2026 20:40
@domgan-oai
domgan-oai merged commit 621147d into octanejs:main Sep 9, 2026
51 checks passed
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.

1 participant