Skip to content

perf(javascript): index returned method analysis - #1520

Closed
geekwolf wants to merge 5 commits into
morluto:mainfrom
geekwolf:fix/js-returned-reference-scaling
Closed

geekwolf wants to merge 5 commits into
morluto:mainfrom
geekwolf:fix/js-returned-reference-scaling

Conversation

@geekwolf

Copy link
Copy Markdown
Contributor

Summary

Fixes #1495.

Avoid quadratic semantic analysis when many object methods return the same reference.

Problem and expected behavior

Resolving each box.mN() call rescanned the complete object literal, and receiver escape handling repeated the same whole-object effect for every call. A 2,000-method reproduction took about 5.6 seconds locally.

Change and scope

  • index static object properties once while preserving duplicate-property, computed-property, and spread semantics
  • reuse receiver escape effects only when the binding and its selected initializer lifetime are identical
  • add the reported 2,000-method regression shape with its semantic assertion

Contract and boundary impact

  • Semantic owner and earliest changed stage: JavaScript semantic member-mutation analysis
  • CLI and MCP/tool-catalog contract: none
  • Provider, bridge, target-format, or platform compatibility: none
  • Evidence, artifact, provenance, or reconstruction contract: preserves existing mutation uncertainty
  • Process execution, authorization, cleanup, or containment impact: none
  • Generated metadata, package, or installation impact: none

Evidence and regression coverage

  • Tests added or updated: returned-object method scaling regression
  • Base reproduction: approximately 5.6 seconds for 2,000 methods/calls on this Windows host
  • Fixed reproduction: approximately 0.3 seconds
  • Remaining proof gaps: not benchmarked on Linux or macOS

Validation performed

  • npx vitest run src/domain/javascript/javascriptSemanticAnalysis.member_mutations.test.ts — 154 passed
  • npx vitest run --project acceptance tests/acceptance/applications/javascriptReturnedReferences.test.ts — passed
  • npm run check:fast — passed
  • npm run build:cached — passed

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@N0zoM1z0

Copy link
Copy Markdown
Collaborator

Main now contains #1517 and #1526. Please rebase this onto current main and focus the follow-up on the static object-target index. The independent 4,000-method profile on main still spends about 1.82 s in selectObjectTargets and its property-loop callback, so indexing addresses a distinct remaining cost. The index appears to retain the reverse-order trailing spread/computed-property candidates and the last known property.

The additional receiver-effect cache drops later escape locations for an unchanged receiver/initializer set. #1517 deliberately keeps those locations while caching only pure syntax expansion. Keeping that existing owner avoids introducing another lifetime/effect-cache rule just to obtain the index improvement; if you retain the effect cache, please demonstrate complete-IR equivalence across multiple capture points, lexical scopes and referenced-binding lifetime changes. A narrow controlled port of the two exact modules matched seven small lifetime cases here, but that is not public CLI/MCP or broad equivalence proof.

Please also remove the new hard 2,000 ms assertion: we observed the equivalent assertion from #1517 fail at 2,332.3 ms on the prescribed two-core host, then fixed its test portability in #1526. Keep semantic regression assertions and publish explicit resource-bound timings separately. Existing duplicate-property, dynamic-property, spread and callable-capture workflows should accompany the index-only change.

@geekwolf

Copy link
Copy Markdown
Contributor Author

Superseded by #1537, which is rebased onto current main and contains only the static object-target index change.

@geekwolf geekwolf closed this Oct 10, 2026
@morluto morluto added performance Performance regressions, scaling limits, and bounded-resource work area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior performance Performance regressions, scaling limits, and bounded-resource work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Many methods returning one object make analysis grow quadratically since #1471

3 participants