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: don't hang in allImportsFixes #59216
Comments
Change https://go.dev/cl/492679 mentions this issue: |
The current logic populates the process env *after* clearing, but clearing uses fields in the process env. To work around this, clearing is not performed on the first run. Chesterton's fence may apply: I don't really understand this, but don't see how it could be correct: if the clearing requires the environment, then the environment should be populated before clearing. For golang/go#59216 Change-Id: Ia0bc0de10284abf9853158e4f7e60de3d338083d Reviewed-on: https://go-review.googlesource.com/c/tools/+/492679 Reviewed-by: Alan Donovan <adonovan@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Change https://go.dev/cl/494095 mentions this issue: |
Add some visibility into goimports operations, by instrumenting spans in top-level imports and gocommand operations. This may be the first time we instrument non-gopls code in this way, but it should be safe as other build targets (e.g. the goimports or gopackages commands) do not set a global exporter, and therefore the cost of event instrumentation should be minimal. For golang/go#59216 Change-Id: Id2f8fe05d6b61e96cdd2d41cc43b3d4c3cf39e21 Reviewed-on: https://go-review.googlesource.com/c/tools/+/494095 Reviewed-by: Alan Donovan <adonovan@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com>
Just encountered this again, and the new instrumentation narrows this down to addExternalCandidates:
|
While this is still a problem, it seems like it only hangs for perhaps 5-10 seconds. The real culprit of hanging in code actions was discovered, and fixed in https://go.dev/cl/496186. goimports isn't going to get rewritten for v0.12.0. Moving to v0.13.0, when hopefully we'll have time to unify goimports and unimported completion, and have a better handle on its execution. |
Thanks to the newly improved trace view, I have noticed that sometimes my gopls gets into a state where it hangs behind 'allImportFixes'. I expect this is the source of the often reported bug of 'waiting for code actions' from VS Code
Sample trace below, where AllImportsFixes took 3s for x/tools. (by comparison, type-checking all of x/tools from scratch takes ~3s).
I don't think we should ever wait a significant amount of time for allImportsFixes. goimports is already imprecise and/or nondeterministic, depending on the state of the module cache.
The text was updated successfully, but these errors were encountered: