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: slow diagnostics after adding/removing an import #61344

Closed
2 tasks
findleyr opened this issue Jul 13, 2023 · 3 comments
Closed
2 tasks

x/tools/gopls: slow diagnostics after adding/removing an import #61344

findleyr opened this issue Jul 13, 2023 · 3 comments
Assignees
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@findleyr
Copy link
Contributor

I just noticed that in certain packages, diagnostics are very slow after adding or removing an import (or making any other metadata-affecting change).

It looks like I introduced an awaitLoaded(...) call into the critical path re-typechecking a package (via resolveImportGraph). When the package being edited is low level, this results in reloading its entire reverse-transitive closure.

As an invariant, we should always be able to operate on the current package without reloading everything.

  • add a benchmark for this operation, which is common thanks to goimports on save
  • fix the logic of resolveImportGraph
@findleyr findleyr added this to the gopls/v0.12.5 milestone Jul 13, 2023
@findleyr findleyr self-assigned this Jul 13, 2023
@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 Jul 13, 2023
@earthboundkid
Copy link
Contributor

I sometime see saving a file in VSCode take an extremely long time, and I've never been able to figure out why, but this sounds like a likely culprit. Good luck fixing it!

@findleyr
Copy link
Contributor Author

Thanks @carlmjohnson. It should not actually be that difficult to fix. I'll be sure to ask you to test once it is done :)

@gopherbot
Copy link

Change https://go.dev/cl/510095 mentions this issue: gopls/internal/lsp: don't awaitLoaded inside resolveImportGraph

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants