fix: invalidate module resolution cache when higher priority file is added #2754
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.
While debugging #2738, I found that the memory usage of svelte-language-server is much higher than that of TSServer when there are many files. It turns out that the way we store the mapping of "failed lookup path" to "containing file" uses a lot of memory. I guess path normalisation might have prevented V8 from optimising the string memory usage, so the same path has multiple instances in the
failedPathToContainingFile
map.In an empty SvelteKit project that imports
googleapis
, which has 800+.d.ts
files and takes around 80 MB, the memory usage went down from around 1.4GB to 1 GB. It's still higher than TServer, but it's a lot closer.Also, a bit embarrassing that the old way I wrote also doesn't completely invalidate the cache, and the test is wrong 😅.