Skip to content

fix: avoid quadratic synthesis line lookups - #1580

Closed
danusha2345 wants to merge 1 commit into
colbymchenry:mainfrom
danusha2345:fix/quadratic-synthesis-line-lookup
Closed

fix: avoid quadratic synthesis line lookups#1580
danusha2345 wants to merge 1 commit into
colbymchenry:mainfrom
danusha2345:fix/quadratic-synthesis-line-lookup

Conversation

@danusha2345

Copy link
Copy Markdown
Contributor

Summary

  • replace the remaining per-match source.slice(0, index).split('\n') line calculations in dynamic-dispatch synthesis with the existing lazy newline index
  • cover ArkUI, Gin, Redux thunk, object registries, Pinia, Vuex, Celery, Spring, MediatR, Sidekiq, Erlang, and Laravel passes
  • pin both synthesized edge line metadata and the absence of the quadratic allocation pattern

Root cause and impact

Several regex-driven resolution passes recalculated a match's line by copying and splitting the entire source prefix. On a match-dense file, doing that once per match makes the final resolution pass quadratic on the main thread; reducing parse workers cannot affect it.

The existing makeLineAt helper builds one newline-offset array lazily per scanned source and resolves each match with a binary search. This keeps edge attribution unchanged while removing repeated prefix allocations.

This addresses one concrete main-thread amplifier relevant to the full-resolution OOM investigation in #1553. It does not claim that every reported 4–6.5 GB case has the same sole cause.

Validation

  • npm run build:kernel
  • npm run build
  • npx vitest run --reporter=dot — 185 files passed; 3120 tests passed, 9 skipped
  • affected synthesizer suites — 12 files, 28 tests passed
  • controlled full-index A/B on a 20,000-match TypeScript fixture (three alternating runs): median 3.81s → 0.75s; median peak RSS 398,356 KB → 376,848 KB
  • semantic graph hashes are identical before and after for nodes, edges, and all 20,001 unresolved references

@danusha2345

Copy link
Copy Markdown
Contributor Author

Folded this exact commit into #1583 as 180c6ea so the quadratic resolution-pass work and the related memory fixes can be reviewed and tested together. Closing this draft as superseded; no code was dropped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant