Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(lsp): release unused documents #23398

Merged
merged 9 commits into from
Apr 17, 2024

Conversation

nayeemrmn
Copy link
Collaborator

The TS language service will call documentRegistry.releaseDocumentWithKey() for sources that aren't found in the graph. We couldn't benefit from that until #23259 because we used to pass all known documents as roots.

Also, don't use sourceFileCache for LSP documents. There is a different ts.SourceFile API which is used by the document registry. Trying to reuse host.getSourceFile()/sourceFileCache was causing sources to be parsed twice I think. Use a separate sourceTextCache.

Like the VSCode TS server does, use a ref counter to count acquisitions of source files and only release when it decrements to 0. Currently this can only move between 1 and 0. But later when we have a ts.LanguageService object per-deno.json-scope, it will count how many scopes are currently interested in each source file.

Replace TsServer::restart() with a more targeted TsServer::cleanup_semantic_cache(). We don't want to lose these ref counts in the middle of the program.

Copy link
Member

@nathanwhit nathanwhit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nayeemrmn nayeemrmn merged commit 24fa5c7 into denoland:main Apr 17, 2024
17 checks passed
@nayeemrmn nayeemrmn deleted the lsp-tsc-release-documents branch April 17, 2024 20:41
littledivy pushed a commit to littledivy/deno that referenced this pull request Apr 19, 2024
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.

3 participants