Optimize module resolution cache for watch and editor #37055
Merged
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.
Before this change we had few issues with the resolution cache.. It only stored resolutions per file. So when something changed we had to go through map and invalidate the resolutions in each file based on what changed. Because earlier resolution was readonly only object with resolution and failed lookup locations, every resolution is distinct even when resolution in say file "/a/b/c.ts" was reused as resolution from file
/a/b/x/d.ts
. The difference was that the later resolution would contain more failed lookup locations but everything else will be same. Given the number of resolutions to go through to invalidate them, we use to skip going through resolutions and just re-evaluate them when asked for if program contained more than 256 files. So there was lot of time spent in module resolution on rename of files or some such updates..This PR makes below changes:
Here are the number of resolutions for vscode source and rename action in repro
Note that ResolutionsToFile I am listing files only if number of resolutions are more than 100 to that file otherwise list gets long...
Note that vscode has 2227 files in the project
This fixes #30535