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

x/tools/gopls: parse dependency ASTs in full mode #38278

Open
stamblerre opened this issue Apr 6, 2020 · 2 comments
Open

x/tools/gopls: parse dependency ASTs in full mode #38278

stamblerre opened this issue Apr 6, 2020 · 2 comments
Labels
gopls/performance Issues related to gopls performance (CPU, memory, etc). gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.

Comments

@stamblerre
Copy link
Contributor

stamblerre commented Apr 6, 2020

We really only use dependency ASTs for finding definitions and documentation, and we can avoid extra work and AST traversal by precomputing what we need. In most cases, dependencies are only type-checked once. I propose this alternative:

  • We type-check all packages in "full" mode (allowing us to use the type information for analyses).
  • Instead of having different parse modes for files, we have different modes for PackageHandles, one for workspace packages (PackageHandle) and one for dependencies (ExportedPackageHandle). PackageHandle remains the same as it is now, while ExportedPackageHandle does not contain references to the package's ParseGoHandles. Rather, it contains a pre-computed table of information that can be used for various features. My guess is that it will be a table of token.Pos -> documentation, but I'm sure I missed things.

/cc @heschik @ianthehat

@stamblerre stamblerre added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 6, 2020
@stamblerre stamblerre added this to the gopls/v0.5.0 milestone Apr 6, 2020
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Apr 6, 2020
@stamblerre stamblerre removed this from the gopls/v0.5.0 milestone Jun 20, 2020
@stamblerre stamblerre added this to the gopls/unplanned milestone Oct 21, 2020
@stamblerre
Copy link
Contributor Author

stamblerre commented Nov 11, 2020

A while back, @findleyr and I discussed a related topic which might allow us to get accurate analysis results for dependencies without the memory cost of keeping full ASTs in memory. Rob suggested that we could try pruning the ASTs after analysis runs, so the facts generated by analyses would be correct, but we would not pay the cost of keeping the full ASTs in memory.

@stamblerre stamblerre changed the title x/tools/gopls: stop caching ASTs for dependencies x/tools/gopls: parse dependency ASTs in full mode Nov 20, 2020
@findleyr findleyr added the gopls/performance Issues related to gopls performance (CPU, memory, etc). label Oct 8, 2021
@CooperLi
Copy link

CooperLi commented Nov 25, 2022

any progress for now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls/performance Issues related to gopls performance (CPU, memory, etc). gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants