do not use ScriptVersionCache for closed files #12777
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.
ScriptVersionCache
internally stores text in tree-like form which is very efficient for editing purposes and at the same time pretty expensive to be used as a generic storage. Size of the tree is proportional to the size of the file and varies from 1.5 x (size of text) for small files through to 3x up to 10x in a degenerate cases (like 40 MB files). As an exampleandroid.d.ts
is ~13 MB file and its tree representation is takes roughly 40 MB.To avoid paying this cost I've introduced
TextStorage
abstraction that internally can either store text as is or useScriptVersionCache
.ScriptVersionCache
is used for open files or for some operations that cannot be efficiently used on plain text (like editing). For all other cases it uses plain text deferring its loading (which is useful for scenarios when language service is disabled).// cc @mhegazy