Skip to content

perf: cut universal native hover allocation with lazy replay identities - #1010

Merged
domgan-oai merged 2 commits into
octanejs:mainfrom
openai-oss-forks:fix/1007-universal-native-allocation
Sep 9, 2026
Merged

domgan-oai merged 2 commits into
octanejs:mainfrom
openai-oss-forks:fix/1007-universal-native-allocation

Conversation

@domgan-oai

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

Copy link
Copy Markdown
Contributor

Summary

  • Defer universal owner replay identity construction until a suspended memo needs matching. Ordinary native updates no longer allocate an identity index and a path array for every nested component.
  • Preserve unkeyed sibling encounter ordinals across render-phase retries and retained boundary owners; add a public object-driver regression for distinct nested pending memos.
  • Add a compiled native hover benchmark with 20 and 80 rows, four view layers per row, 2,000 real events per sample, host identity and prop checks, teardown checks, and a scaling guard. Register the suite in the MCP server's benchmark list.

Why

Issue #1007 reports 3.88 GB cumulative JavaScript allocation and heavy Hermes GC in a 20-row native hover workload. The renderer was eagerly building replay identities for every owner on every update even when no memo suspended. That work is now paid only by pending memo replay.

Performance evidence

On Node 26.4.0/V8, macOS arm64, in the same public compiled object-driver workload and with the same 2 KiB Inspector allocation sampler (including objects collected by GC), a warmed 20-row, 2,000-hover sample allocated an estimated 2,334,311,200 → 1,495,282,392 bytes (−839,028,808 bytes; −35.9%). These were separate immutable production builds from f86fb48c and the original lazy-replay diff, before #1009 merged. Both runs verified stable host structure, correct selection, and teardown. The 80/20 same-run hover timing ratio on this branch was 4.97 against an 8.0 guard; concurrent local tests made absolute timings noisy. Built universal-core.js changed by +50 raw bytes and +63 gzip bytes. After merging #1009, both production benchmark suites passed their semantic controls; the hover 80/20 timing ratio was 4.24 against the 8.0 guard.

Validation

  • pnpm sync — no generated changes, including after merging current main (0ba4016c).
  • pnpm format:files:check on changed files.
  • ./node_modules/.bin/vitest run packages/octane/tests/universal*.test.ts --reporter=dot — 714/714 tests in dev and production after the final runtime edit.
  • ./node_modules/.bin/vitest run packages/octane-mcp-server/src/index.test.js --reporter=dot — 15/15 tests after adding the suite list entry.
  • Post-merge ./node_modules/.bin/vitest run packages/octane/tests/universal*.test.ts packages/octane-mcp-server/src/index.test.js --reporter=dot — 731/731 tests across 37 files.
  • pnpm --filter octane exec tsrx-tsc --noEmit --project tsconfig.json.
  • BENCH_OCTANE_DIST=<production dist> BENCH_ALLOCATION_JSON=<profile> node benchmarks/universal-native-hover/run.mjs 1 — both pinned builds passed semantic checks and yielded the profiles above.
  • pnpm format:check.
  • pnpm typecheck.
  • pnpm test — full local run encounters macOS Chromium sandbox launch failures (MachPortRendezvousServer permission denied); targeted native suite and CI are the relevant gates. The run also exposed the benchmark list omission, now fixed and retested.

Risk / follow-ups

  • The issue's standalone Hermes harness is unavailable. V8 allocation estimates are not Hermes GC evidence. The candidate still allocates about 1.50 GB in this diagnostic workload, so this PR is a measured reduction rather than parity with Solid; High allocation volume and GC overhead in octane/universal/native on Hermes #1007 should remain open for further owner/materialization work and a Hermes rerun.
  • Fresh callback props in the row fixture require all 20 row components to render on each hover under current semantics. The separate draft collection optimization merged in perf: reuse universal owner draft collections #1009 and is included through the merge commit; this PR diff remains focused on lazy replay identities.

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
Changes universal-core Suspense memo replay identity construction; incorrect ordinals or lazy paths could mis-associate pending memos across siblings or retries, though new and existing universal tests target this.

Overview
Defers building universal owner replay paths until Suspense needs to match a pending memo (findSuspendedMemo / collectSuspendedMemos call ownerReplayPath). Ordinary native updates no longer eagerly maintain childReplayOrdinals or a replay segment for every nested owner claim.

Unkeyed sibling ordinals for replay matching now come from a priorClaimedSibling claim chain (including retained Activity owners), replacing per-render identity-index updates. A semantics regression covers distinct nested pending memos after a render-phase retry.

Adds the universal-native-hover Node benchmark (issue #1007): compiled 20/80-row, four-layer hover selection with correctness probes, an 80/20 timing ratio guard, and runner/MCP registration. Patch changeset documents the allocation win.

Reviewed by Cursor Bugbot for commit ecf1ed3. 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 08:34
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