Skip to content

perf: keep memo wrappers on stable shapes - #1014

Merged
domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/memo-wrapper-shapes-981
Sep 9, 2026
Merged

domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/memo-wrapper-shapes-981

Conversation

@domgan-oai

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

Copy link
Copy Markdown
Contributor

Summary

  • Keep distinct client and server memo() wrapper functions on stable V8 property shapes with shared metadata accessors and a private owner marker.
  • Preserve live defaultProps, nested wrappers, comparator behavior, and protection against a full static-hoisting HOC accidentally becoming a memo boundary. Add client/server regressions and a registered production benchmark.
  • Follow up on Track V8 performance audit findings across runtime, SSR, universal core, and compiler output #981's memo() wrapper finding.

Why

On merged main (1c28da5), V8 reports fast properties for only the first memo() wrapper; later wrappers enter dictionary mode because each getter/setter is a fresh function. The production baseline reproduces this in both runtimes. The new benchmark samples 128 and 1,024 distinct wrappers rather than the single wrapper in memo-wall.

Validation

  • pnpm format:files:check for all changed files; git diff --check
  • pnpm typecheck
  • pnpm sync; changeset validation
  • Targeted client/server tests in development and production projects: 164/164; new tests deliberately failed under broken default forwarding and copied marker behavior, then passed after restoration.
  • MCP benchmark catalog tests: 15/15; node benchmarks/bench.mjs --quick memo-wrapper-shapes
  • Frozen production baseline and candidate: 24/24 semantic hashes match in paired runs. V8 fast-property samples change from 1/128 and 0/1,024 to 128/128 and 1,024/1,024 on both runtimes.
  • pnpm test: the repository-wide run was stopped after unrelated browser suites failed; an isolated Aria case confirmed Chromium exits at launch with macOS Mach port Permission denied (1100), before executing the test. Current-head CI passed all 26 jobs, including browser integration and React parity; Cursor Bugbot passed without findings.

Risk / follow-ups

  • Timing controls drifted several-fold across B–C–C–B and B–C–B–C pairs, so these measurements do not establish a throughput improvement. The benchmark records the shape change and matched behavior; application-level timing is still open.
  • A consumer copying only a defaultProps accessor descriptor to an unrelated function must also copy type for live forwarding. Full static hoisting remains covered by regressions; an isolated descriptor copy used to retain the original component through a per-wrapper closure.

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 core memo() metadata on both runtimes; behavior is heavily regression-tested, but incorrect descriptor sharing could break memo detection, defaultProps forwarding, or HOC static copying.

Overview
Client and server memo() no longer attach fresh getter/setter closures on every wrapper. Each wrapper gets a private MEMO_OWNER marker, then reuses shared descriptors for __memo (owner-bound marker) and defaultProps (live read/write via type), so many distinct wrappers stay on the same hidden-class shape while static hoisting still cannot turn an copied HOC into a memo boundary.

Adds the Node-only memo-wrapper-shapes benchmark (128/1,024 wrappers, client/server isolates, semantic hashes, V8 fast-property diagnostics) and wires it into bench.mjs, benchmark docs, and the MCP suite catalog. Client audit and SSR element tests cover distinct/nested memos, live defaults, and hoisted statics.

Patch changeset for octane and @octanejs/mcp-server.

Reviewed by Cursor Bugbot for commit aa172b5. 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 12:46
@domgan-oai
domgan-oai merged commit 3606d04 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