Repository navigation
perf(octane): look up own memo props only for values an inherited read can produce - #1661
Merged
Merged
Conversation
…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]>
trueadm
marked this pull request as ready for review
October 3, 2026 10:06
Contributor
Benchmark report
Compares js-framework: 1k/10k row operations (ms, lower is better)All 20 timed operations (20 within noise)
Application bundle size (bytes)
30 other measured values are unchanged. Public-import reachability bundles (bytes)
75 other measured values are unchanged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
shallowEqualPropscallhasOwnPropertyfor every key, so an inheritedObject.prototypevalue cannot stand in for a removed own prop. On a plain or null-prototype object, a missing own prop reads asundefinedor as anObject.prototypemember, 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 forundefined, 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_Bis 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):
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 toundefinedonly (the pre-fix(memo): compare own prop membership #1279 shape) fails 64 of them.__proto__prop that holdsObject.prototype, through a template spread that keeps the own key, must re-render. It fails without theobjectbranch and passes on main and here.createElementturns__proto__into a prototype assignment, so only the spread path carries it.memo-wall/bail-compare.mjscountshasOwnPropertycalls 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.memo-props,memo-value-position(--project octane, 123 passed),conformance/memo-bailout(--project octane-prod, 4 passed).pnpm typecheck:fileson 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.prototypecarries no primitive data property under a removed prop's name with an equal value; only prototype pollution creates one. React'sshallowEqualchecks every key. This keeps every non-polluted case exact, including all fix(memo): compare own prop membership #1279 transitions.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith 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
hasOwnPropertyfor primitive props that already match viaObject.is, and only checks ownership when the value isundefined, 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 inheritedObject.prototypereads as distinct from missing own props.Adds a memo-wall micro-benchmark (
bail-compare.mjs) that countshasOwnPropertyper bailed row (budget 1 vs main’s 5 for the fixture), plus baseline ratio wiring. Tests cover replacing an own__proto__prop holdingObject.prototypevia template spread (KeysHostfixture).Reviewed by Cursor Bugbot for commit 8c52cf0. Bugbot is set up for automated code reviews on this repo. Configure here.