Repository navigation
Conversation
…ty write Repeated property writes to one object made member-mutation collection cubic. Each write evaluated its target binding to rule out a primitive, and every evaluation folded all earlier mutation paths, copying every slot once per path. 2,000 writes to one object took 27 s and 4,000 took 203 s. - A recorded write always leaves a non-primitive binding value, so only the first write to a binding needs the primitive check. - Apply mutation paths per slot in one pass with the same ordering semantics instead of one full slot copy per path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Independent review of the final integrated head I preserved the contributor commit/history and merged current main into the original contributor branch. The actual original branch ancestor was
No real Hopper/Ghidra verification was needed for this JavaScript-only fix. Final-head CI is still pending the remaining platform lanes; merge remains conditional on their success. |
|
TL;DR: #1444 merged as I started, so I tested the merge commit SpeedAnalysis time on Node 24, median of 3. Base at 4,000 ran once.
Five other shapes behave the same way. Head stays under 0.6 s at 4,000 on Node 22, 24 and 26. The output hash matches base at every size. SoundnessEach case ran through the CLI or
14 rows in the #1390 set have no real value. Real JS throws on every run there. Base and head match on those too. The counts are the same on base and head. Head lost no right answer and gained none. The output was byte for byte the same on every case. All 9 wrong rows were wrong on base too. Six are the call-return bug in #1449. This PR leaves them as they were. The new probes cover overwrites, I also fuzzed the new fold against the old one. That was 900,000 random value and path runs. Both gave the same result every time. Tests
Not run
Thanks, zeynelacikgoez. The grouped fold is a neat fix, and the notes in the PR made it easy to check. Speed for all shapesMedian analysis time of 3 runs. Base ran once when a run took over 60 s. A star means the box was busy, so read it as rough.
The 9 wrong rows (same on base and head)
How I checked
Test setup
🤖 Generated with Claude Code (Opus 5.5) 🦊 |
Summary
Member-mutation collection is still cubic in the number of property writes to a single object on current
main. CommonJS/webpack exports objects and minified configuration builders make this pattern common in real bundles. Onmain(0b9815b6),analyzeJavaScriptSemanticstakes 27 s for 2,000 writes to one object and 203 s for 4,000. With this change, those take 0.09 s and 0.16 s.This is separate from #1401, which
28595276fixed (factorial growth through reassignment loops). That fix bounds path enumeration. The cost here is in evaluating the written binding.Problem and expected behavior
Smallest trigger:
There are two compounding costs in
collectSemanticMemberMutationsandevaluateBinding:evaluateSemanticBindingon its target, only to rule out a primitive target, because writes to primitives are ignored.binding.mutatedPathswithinvalidateSemanticMutationPathcopies the whole slot array once per path, so one evaluation costs O(k · slots).Together that is O(k²·(slots + k)). Expected behavior: cost proportional to the writes, with identical values.
Change and scope
javascriptSemanticMemberMutations.ts).invalidateSemanticMutationPathreturns either an object/array orunknown, never a literal/union.javascriptSemanticMutationValues.ts,javascriptSemanticValues.ts).invalidateSemanticMutationPaths(value, paths)groups paths per slot and recurses once per slot.null/empty key ⇒ the same rootunknown, which subsumes the existing early break;lengthwrite resets items;unknown-coverageslot;Not included: no caps or truncation, no change to cycle handling from
28595276, and no contract, schema, or catalog change.Contract and boundary impact
src/domain/javascriptmember-mutation collection and binding evaluation.Evidence and regression coverage
Test added:
javascriptSemanticAnalysis.member_mutations.test.ts› "records each write to one object without replaying earlier writes".literaland the written slot isunknown, within 2 s.expected 42984 to be less than 2000).Base reproduction on Node 24.18.0 / macOS arm64:
main0b9815b6.webpack/main/index.js(4.2 MB) 10.6 s → 8.7 s;.webpack/renderer/activity_monitor/index.js0.98 s → 0.95 s.Value equivalence:
app.asar, all 58,900 binding and return-site values are byte-identical betweenmainand this change.nullkeys,length, duplicate names, nesting) fold identically to the sequential per-pathreduce.Commands run:
npm run check:fast, which passes.npm run test:local -- src/domain/javascript/*.test.ts src/application/javascript/*.test.ts: 55 files, 989 tests, passing.npm run test:focused --with the 42 JavaScript CLI/MCP/composition test files: 286/290 passed. All 4 failures were 30 s timeouts intests/acceptance/applications/exportedFunctionBindingsCli.test.tsandtests/acceptance/tools/localToolContracts.test.ts. Run alone, those two files also time out on unmodifiedmainon this machine (5 failures there vs 3 with this change).Real Hopper/Ghidra verification: not applicable; JavaScript-only change.
🤖 Generated with Claude Code