-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/lsp/cache: add an LRU parse cache
As work proceeds on incremental type-checking, two observations have emerged from benchmarking: - Using a global FileSet is impossible, as IImportShallow allocates a large number of new token.Files (in early experiments 75%+ of in-use memory was consumed by the FileSet!) - Several benchmarks regressed with incremental type-checking due to re-parsing package files following a change. Ideally after a single file changes we would be able to re-typecheck packages containing that file after only re-parsing the single file that changed. These observations are in tension: because type-checking requires that parsed ast.Files live in the same token.FileSet as the type-checked package, we cannot naively save the results of parsing and still use a package-scoped FileSet. This CL seeks to address both observations, by introducing a new mechanism for caching parsed files (a parseCache) that parses files in a standalone FileSet offset to avoid collision with other parsed files. This cache exposes a batch API to parse multiple files and return a FileSet describing all of them. Benchmarking indicates that this partially mitigates performance regressions without sacrificing the memory improvement we by avoiding a global cache of parsed files. In this CL the parse cache is not yet integrated with type-checking, but replaces certain call-sites where we previously tried to avoid parsing through the cache. For golang/go#57987 Change-Id: I840cf003db835a40721f086abcc7bf00486b8108 Reviewed-on: https://go-review.googlesource.com/c/tools/+/469858 Reviewed-by: Alan Donovan <adonovan@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> Run-TryBot: Robert Findley <rfindley@google.com>
- Loading branch information
Showing
14 changed files
with
509 additions
and
119 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.