Skip to content

perf(octane): look up own memo props only for values an inherited read can produce - #1661

Merged
trueadm merged 1 commit into
mainfrom
perf/memo-own-prop-compare
Oct 3, 2026
Merged

trueadm merged 1 commit into
mainfrom
perf/memo-own-prop-compare

Conversation

@trueadm

@trueadm trueadm commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The memo bail now does an own-property lookup only for prop values that an inherited read could also produce.

#1279 (2026-09-23) made the plain-object shallowEqualProps call hasOwnProperty for every key, so an inherited Object.prototype value cannot stand in for a removed own prop. On a plain or null-prototype object, a missing own prop reads as undefined or as an Object.prototype member, which is a function, or an object for the __proto__ accessor. A primitive that compares equal is therefore already the object's own. The lookup now runs only for undefined, function and object values. Rows that pass mostly strings and numbers bail with one lookup instead of one per prop.

Why

memo-wall one_change_B is waived on #1646 as a confirmed regression: wall B re-creates 1,000 descriptors and 999 rows bail on equal values. Each row has four primitive props and one callback, so #1279 added five lookups per bailed row.

Same-runner paired A/B, run 37114615678, ms per one-row change (React Compiler reference 0.190):

pre-#833 main #1655 + #1656 + this PR
0.197 0.285 0.269 0.252

That puts one_change_B at 1.33× React with all three PRs, against the 1.4 ceiling. The rest of the gap is spread across intentional later work: #833 input journaling for every survivor whose descriptor changed, #1069 signal-owner checks in renderBlock, the render-phase update loop, and scoped key derivation. So the waiver's numbers, rather than one cause, should decide whether it can go.

Validation

  • memo-props.test.ts (fix(memo): compare own prop membership #1279's 121 cases) passes. Narrowing the lookup to undefined only (the pre-fix(memo): compare own prop membership #1279 shape) fails 64 of them.
  • New case: replacing an own __proto__ prop that holds Object.prototype, through a template spread that keeps the own key, must re-render. It fails without the object branch and passes on main and here. createElement turns __proto__ into a prototype assignment, so only the spread path carries it.
  • New deterministic guard: memo-wall / bail-compare.mjs counts hasOwnProperty calls per bailed row (difference between 128 and 256 rows). It reads 5 on main and 1 here, against a budget of 1 (the callback), with render-probe, host-identity and one-changed-row controls.
  • targeted tests: memo-props, memo-value-position (--project octane, 123 passed), conformance/memo-bailout (--project octane-prod, 4 passed).
  • pnpm typecheck:files on the changed files; pnpm format:files; pnpm sync.
  • pnpm test, pnpm typecheck, pnpm format:check: left to CI.

Risk / follow-ups

  • Bytes: the type check costs +56 raw / about +20 gzip in bundles that reach memo (bench report). Equivalent spellings are no shorter, and dropping cases would only add lookups back.

  • The narrowing assumes Object.prototype carries no primitive data property under a removed prop's name with an equal value; only prototype pollution creates one. React's shallowEqual checks every key. This keeps every non-polluted case exact, including all fix(memo): compare own prop membership #1279 transitions.

Provenance

  • An agent produced this diff (agent-authored)

🤖 Generated with Claude Code


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 hot-path memo equality semantics; correctness relies on no primitive pollution on Object.prototype, though existing #1279 transition tests and a new __proto__ case are covered.

Overview
Memo bail shallow prop compare on plain objects now skips hasOwnProperty for primitive props that already match via Object.is, and only checks ownership when the value is undefined, a function, or an object—so typical list rows (mostly strings/numbers plus one callback) do one lookup per bail instead of one per key, while still treating inherited Object.prototype reads as distinct from missing own props.

Adds a memo-wall micro-benchmark (bail-compare.mjs) that counts hasOwnProperty per bailed row (budget 1 vs main’s 5 for the fixture), plus baseline ratio wiring. Tests cover replacing an own __proto__ prop holding Object.prototype via template spread (KeysHost fixture).

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

…d can produce

#1279 made the plain-object memo compare check own-property membership for
every key, so an inherited Object.prototype value cannot stand in for a
removed prop. On a plain or null-prototype object a missing own prop reads as
undefined or an Object.prototype member, which is a function or an object, so
a primitive that compares equal is already own. The lookup now runs only for
undefined, function and object values.

memo-wall's wall B bails 999 rows of four primitive props and a callback on
every one_change_B; it made five lookups per row and now makes one. Paired
A/B with the #833/#1069 fixes: one_change_B 0.269 -> 0.252 ms.

memo-props gains a case for an own __proto__ prop holding Object.prototype
(the object branch; it fails without it), and memo-wall gains a deterministic
guard counting own-prop lookups per bailed row (5 on main, 1 now).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work labels Oct 3, 2026
@trueadm
trueadm marked this pull request as ready for review October 3, 2026 10:06
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🔴 bundle-size: 11 value(s) increased
  • 🔴 bundle-reachability: 25 value(s) increased

Compares a0df40945 with ce9dd7c0b on the same runner. Timing verdicts require a change beyond the combined margin of error (at least 5%) and one 0.1ms timer tick, with the fastest sample also moving beyond that margin. Workflow run

js-framework: 1k/10k row operations (ms, lower is better)

All 20 timed operations (20 within noise)
target operation base head Δ noise
octane-tsrx run 3.20 3.42 +6.9% ±17% ⚪ within noise
octane-tsrx replace 6.61 7.38 +11.6% ±40% ⚪ within noise
octane-tsrx add 3.35 3.18 −5.1% ±19% ⚪ within noise
octane-tsrx update 0.37 0.39 +5.4% ±46% ⚪ within noise
octane-tsrx select 0.19 0.13 −31.6% ±75% ⚪ within noise
octane-tsrx swap 0.34 0.39 +14.7% ±53% ⚪ within noise
octane-tsrx remove 0.38 0.37 −2.6% ±31% ⚪ within noise
octane-tsrx runlots 29.31 29.66 +1.2% ±25% ⚪ within noise
octane-tsrx select_lots 0.26 0.30 +15.4% ±47% ⚪ within noise
octane-tsrx clear 43.10 44.09 +2.3% ±5% ⚪ within noise
octane-jsx run 3.52 3.38 −4.0% ±30% ⚪ within noise
octane-jsx replace 6.34 6.70 +5.7% ±13% ⚪ within noise
octane-jsx add 3.08 3.11 +1.0% ±11% ⚪ within noise
octane-jsx update 0.49 0.49 ±0.0% ±32% ⚪ within noise
octane-jsx select 0.36 0.40 +11.1% ±28% ⚪ within noise
octane-jsx swap 0.62 0.59 −4.8% ±19% ⚪ within noise
octane-jsx remove 0.59 0.66 +11.9% ±36% ⚪ within noise
octane-jsx runlots 26.55 27.80 +4.7% ±6% ⚪ within noise
octane-jsx select_lots 2.57 2.60 +1.2% ±29% ⚪ within noise
octane-jsx clear 44.65 46.65 +4.5% ±7% ⚪ within noise

Application bundle size (bytes)

target metric base head Δ
octane-tsrx weather_js_raw 176,630 176,686 +56 (+0.0%) 🔴
octane-tsrx weather_js_gzip 57,749 57,768 +19 (+0.0%) 🔴
octane-tsrx weather_js_brotli 50,357 50,349 −8 (−0.0%) 🟢
octane-tsrx weather_app_gzip 9,045 9,044 −1 (−0.0%) 🟢
octane-tsrx weather_app_brotli 7,619 7,607 −12 (−0.2%) 🟢
octane-tsrx weather_fw_raw 149,895 149,951 +56 (+0.0%) 🔴
octane-tsrx weather_fw_gzip 48,704 48,724 +20 (+0.0%) 🔴
octane-tsrx weather_fw_brotli 42,738 42,742 +4 (+0.0%) 🔴
octane-jsx js_raw 226,632 226,688 +56 (+0.0%) 🔴
octane-jsx js_gzip 72,341 72,360 +19 (+0.0%) 🔴
octane-jsx js_brotli 62,641 62,695 +54 (+0.1%) 🔴
octane-jsx app_brotli 2,497 2,496 −1 (−0.0%) 🟢
octane-jsx fw_raw 218,173 218,229 +56 (+0.0%) 🔴
octane-jsx fw_gzip 69,405 69,424 +19 (+0.0%) 🔴
octane-jsx fw_brotli 60,144 60,199 +55 (+0.1%) 🔴

30 other measured values are unchanged.

Public-import reachability bundles (bytes)

target metric base head Δ
root-static raw 202,869 202,925 +56 (+0.0%) 🔴
root-static gzip 64,528 64,546 +18 (+0.0%) 🔴
root-static brotli 55,936 55,991 +55 (+0.1%) 🔴
context raw 109,005 109,061 +56 (+0.1%) 🔴
context gzip 36,057 36,069 +12 (+0.0%) 🔴
context brotli 31,926 31,983 +57 (+0.2%) 🔴
deferred-hydration raw 236,115 236,171 +56 (+0.0%) 🔴
deferred-hydration gzip 74,648 74,668 +20 (+0.0%) 🔴
deferred-hydration brotli 64,412 64,515 +103 (+0.2%) 🔴
suspense-transition raw 164,948 165,004 +56 (+0.0%) 🔴
suspense-transition gzip 52,939 52,958 +19 (+0.0%) 🔴
suspense-transition brotli 46,342 46,352 +10 (+0.0%) 🔴
binding-base-ui-vite raw 213,100 213,156 +56 (+0.0%) 🔴
binding-base-ui-vite gzip 68,108 68,128 +20 (+0.0%) 🔴
binding-base-ui-vite brotli 59,019 59,031 +12 (+0.0%) 🔴
binding-base-ui-esbuild raw 211,053 211,109 +56 (+0.0%) 🔴
binding-base-ui-esbuild gzip 68,068 68,089 +21 (+0.0%) 🔴
binding-base-ui-esbuild brotli 59,025 59,022 −3 (−0.0%) 🟢
binding-radix-vite raw 215,032 215,088 +56 (+0.0%) 🔴
binding-radix-vite gzip 68,660 68,680 +20 (+0.0%) 🔴
binding-radix-vite brotli 59,632 59,612 −20 (−0.0%) 🟢
binding-radix-esbuild raw 212,945 213,001 +56 (+0.0%) 🔴
binding-radix-esbuild gzip 68,650 68,672 +22 (+0.0%) 🔴
binding-radix-esbuild brotli 59,604 59,579 −25 (−0.0%) 🟢
binding-apollo-client-vite raw 358,115 358,171 +56 (+0.0%) 🔴
binding-apollo-client-vite gzip 112,223 112,245 +22 (+0.0%) 🔴
binding-apollo-client-vite brotli 98,004 97,830 −174 (−0.2%) 🟢
binding-apollo-client-esbuild raw 361,060 361,116 +56 (+0.0%) 🔴
binding-apollo-client-esbuild gzip 114,405 114,428 +23 (+0.0%) 🔴
binding-apollo-client-esbuild brotli 99,739 99,727 −12 (−0.0%) 🟢

75 other measured values are unchanged.

@trueadm
trueadm merged commit d496796 into main Oct 3, 2026
53 checks passed
@trueadm
trueadm deleted the perf/memo-own-prop-compare branch October 3, 2026 10:20
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