Skip to content

x/tools/gopls: recursive orphaned file reloading #59318

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

Closed
findleyr opened this issue Mar 29, 2023 · 2 comments
Closed

x/tools/gopls: recursive orphaned file reloading #59318

findleyr opened this issue Mar 29, 2023 · 2 comments
Labels
FrozenDueToAge gopls/metadata Issues related to metadata loading in gopls gopls/performance Issues related to gopls performance (CPU, memory, etc). 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
Member

While investigating #59184, I found what I think may be a long-standing bug in gopls that potentially explains many user reports (such as #54007).

Therefore, if orphaned file reloading tries to load N files, it will call go/packages once with N file= queries, which invokes go list N times. The load will succeed, because it produces at least one package, but only one command-line-arguments package will be recorded. The next time orphaned file reloading occurs, it will retry with N-1 files.

I.e. orphaned reloading involves N^2 go list invocations...

CC @adonovan

@findleyr findleyr added gopls/performance Issues related to gopls performance (CPU, memory, etc). gopls/metadata Issues related to metadata loading in gopls labels Mar 29, 2023
@findleyr findleyr added this to the gopls/v0.12.0 milestone Mar 29, 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 Mar 29, 2023
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/480197 mentions this issue: gopls/internal/lsp/cache: record unloadable files if loading completes

gopherbot pushed a commit to golang/tools that referenced this issue Mar 29, 2023
As reported in golang/go#59318, orphaned file reloading may be
accidentally quadratic if it makes progress on every load.

Adjust the logic to record unloadable files whenever loading completes
without cancellation. This fixes golang/go#59184, but is only one half
of fixing golang/go#59318, as we must also fix the package IDs used for
command-line-arguments packages.

Fixes golang/go#59184
For golang/go#59318

Change-Id: Ibbb572b1f65832306b6046d29befa40817be3a28
Reviewed-on: https://go-review.googlesource.com/c/tools/+/480197
TryBot-Result: Gopher Robot <[email protected]>
gopls-CI: kokoro <[email protected]>
Reviewed-by: Alan Donovan <[email protected]>
Run-TryBot: Robert Findley <[email protected]>
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/494401 mentions this issue: internal/lsp/cache: support loading multiple orphaned files

@golang golang locked and limited conversation to collaborators May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls/metadata Issues related to metadata loading in gopls gopls/performance Issues related to gopls performance (CPU, memory, etc). 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

2 participants