Skip to content

perf: bring native hover allocations close to Solid - #1044

Merged
domgan-oai merged 3 commits into
octanejs:mainfrom
openai-oss-forks:codex/investigate-1007-user-repro
Sep 10, 2026
Merged

domgan-oai merged 3 commits into
octanejs:mainfrom
openai-oss-forks:codex/investigate-1007-user-repro

Conversation

@domgan-oai

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

Copy link
Copy Markdown
Contributor

Summary

  • Add opt-in universalHostBinding(source, select) for ordinary properties on local direct native roots. A root shares one source subscription and publishes changed properties together without rerendering the component tree.
  • Release superseded effect callbacks after accepted universal commits so a mounted tree does not retain earlier render closures.
  • Include a patch against the reporter's Hermes reproduction and public regression tests for batching, aborts, hidden hosts, cleanup, scheduler failures, and selector collection.

Why

The reporter's issue and reproduction distinguish mounted retention from cumulative allocations. Releasing effect history fixes the mounted retention, but the hand-authored root useState route still reconstructs 20 rows and 80 view layers on every hover. The new binding route lets that source update the two changed host properties in an accepted batch.

Changes

  • Host bindings subscribe after host acceptance, use the latest source value, and publish changed host props through a specialized local transaction with the same acceptance and abort behavior. They unsubscribe on replacement, hide, and unmount. Unsupported transport, bridge, event, and compact leaf cases fail explicitly.
  • A failed new source subscription leaves healthy accepted hosts connected; shared listeners do not retain removed selectors; source notifications during a prepared transaction drain after commit or abort. Simultaneous scheduled host and bound source errors are both reported.
  • The checked-in reporter patch changes the Octane useState source to a scoped signal and bound active props; the original Solid workload and host/effect assertions remain intact. Reproduction commands are in benchmarks/universal-native-hover/README.md.

Validation

  • Focused universal renderer tests, development and production projects: 42 files, 766 tests passed.
  • Full pnpm typecheck; scoped tsgo --noEmit -p packages/octane/tsconfig.json on the final core.
  • Repository-wide prettier --check . (the pnpm format:check command) and changed-file formatting checks.
  • Original Hermes 1.0.0 Hades harness with the reporter's host driver and a real scoped signal, 2,000 hovers: Octane 9,182,120 B cumulative allocations, 0.94 MB mounted live after GC, 7 collections; Solid 5,823,776 B, 0.37 MB, 6 collections. Both produce 101 hosts, 3,999 property changes, 2,000 events, 80 effect creates/cleanups, and zero hosts after unmount.
  • pnpm test — attempted locally; broad browser and unrelated package suites failed in this macOS environment. Current-head CI is the gate for the full matrix.

Risk / follow-ups

  • The fine-grained route is opt-in. Existing root useState updates still rebuild the hand-authored tree and retain their cumulative allocation cost. The measured opt-in path is about 1.58× Solid's cumulative bytes and 2.57× its mounted live bytes, with the same 8 MiB heap capacity. Controlled diagnostic substitutions attribute about 1.24 MB to the scoped signal versus a minimal source and about 0.90 MB to the reporter's host property traversal; neither substitution is in the final comparison.
  • Bindings currently support local direct roots and ordinary update-only host properties. Transported roots, DOM-owned bridges, event props, and specialized compact leaf descriptors need separate designs.

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 universal root commit/scheduling, subscription lifetimes, and effect hook retention in core universal-core.ts; behavior is opt-in but errors and partial-failure paths are intricate.

Overview
Adds opt-in universalHostBinding(source, select) so local direct native roots can push { get, subscribe } changes (e.g. scoped signals) straight to ordinary host props in one accepted driver batch, without rerunning the component tree. The root deduplicates subscriptions per source, wires bindings after host acceptance, uses a dedicated binding transaction path, and tears down on replace/hide/unmount; transported/bridge/event/compact-leaf cases are rejected.

Separately, accepted universal commits clear superseded effect hook previous links, so stable native renders with unchanged effect deps no longer keep old callback closures alive while mounted.

Docs and the native-hover benchmark README document the binding API, Hermes repro steps, and a reporter patch; large regression and GC retention tests cover batching, aborts, scheduler failures, and cleanup.

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

@domgan-oai
domgan-oai marked this pull request as ready for review September 10, 2026 22:46
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work labels Sep 10, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit 9ec3211. Configure here.

Comment thread packages/octane/src/universal-core.ts Resolved
Comment thread packages/octane/src/universal-core.ts Resolved
@domgan-oai
domgan-oai merged commit c31f629 into octanejs:main Sep 10, 2026
30 checks passed
trueadm added a commit that referenced this pull request Oct 3, 2026
…nch (#1651)

frame_1k_subscribers regressed to 1.18-1.33x React Three Fiber at #1044.
Octane's dispatch did not get slower. #1044 stopped retaining each effect's
previous closures, and the bench built a fresh recordFrame callback on every
render(). V8 inlines that callback into the frame loop; once Octane frees it,
the runner's forced gc() before each sample clears it and deoptimizes the loop,
so the timed frames re-warm V8. React keeps the old props alive through its
alternate fibers, so R3F's call site goes polymorphic and stays optimized.

Both pages now pass module-level checksum callbacks. On the unchanged runtime
frame dispatch measures 0.81x R3F, and every three-renderer op stays below 1.0.

Co-authored-by: Claude Opus 5.5 <[email protected]>
trueadm added a commit that referenced this pull request Oct 3, 2026
… to renderers that use them (#1652)

* perf(octane): ship universal host bindings and template programs only to renderers that use them

Weekly Bench's three-bundle-size guards breached at 1.059x (minimal) and
1.042x (full catalogue) of React Three Fiber. Since #677, octane-min grew
15.6 KB gzip, almost all of it in universal-core.ts (131 KB -> 178 KB
minified). The largest additions were Lynx-only template paths (#693, #700,
#716, #750) and opt-in host bindings (#1044). @octanejs/three itself was flat.

- universalHostBinding() now installs the subscription, flush, and
  binding-only transaction code on its first call. The root keeps one lazy
  binding state instead of seven eager fields, and commits skip the
  per-host binding loops when no binding can exist.
- Template programs are a driver opt-in: templateProgramMount,
  templateProgramRuns, and collapsedTemplateMount take effect only with
  `templates: universalHostTemplates`. The Lynx background driver passes it.
  Program preparation, collapsed-template materialization and expansion, and
  the compact template update now sit behind that object.

octane-min 199019 -> 193811 gzip (1.031x), octane-full 260746 -> 255569
(1.021x). The guards ratchet to 1.034 and 1.024; reaching 1.0 needs a
broader universal-core diet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* chore: split the Lynx changeset from the octane changeset

The changeset check rejects a changeset that mixes the ignored private
@octanejs/lynx package with octane.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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