fix: avoid quadratic synthesis line lookups - #1580
Closed
danusha2345 wants to merge 1 commit into
Closed
Conversation
Contributor
Author
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
source.slice(0, index).split('\n')line calculations in dynamic-dispatch synthesis with the existing lazy newline indexRoot 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
makeLineAthelper 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:kernelnpm run buildnpx vitest run --reporter=dot— 185 files passed; 3120 tests passed, 9 skipped