-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/gopls: Either gopls cache always invalidates on 2nd save for M1 mac (or darwin, not sure) or vs code extension host fails, same config works perfectly on linux. #54007
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
Comments
Sorry for the slow response on this (several folks have been on vacation here), and thank very much for the detailed analysis! I'd like to try investigating, if you're still able to help. One starting point would be to try installing gopls@master. We're working very actively on cache invalidation and performance, and so it's worth confirming that the issue persists at tip.
Just to be clear: you are saving a Naively, I can think of a couple potential culprits:
Needless to say a repro would be extremely helpful here, but I think you've also given us enough information to start investigating. |
I'm trying to understand this, and have a few additional questions:
This doesn't make sense to me. That dep should be a package ID, not a file name. Can you share more details about this error message?
Can you tell me more about the c compiler issues you experience?
Hmm. Can you try just clearing your modcache? (and then not running a subsequent build)? Do the problems go away in that case? (perhaps the slowness is experienced during module cache scanning). On that note: do you have any other external processes that may populate the module cache on the first save? Finally, can you try installing the next gopls version to confirm that the problem persists? There are a large number of changes related to loading in this release, and it would be good to confirm that we still see the same behavior.
|
I believe the root cause of this issue may be https://go.dev/issue/59216. That issue is slated for v0.12.0, but this issue is not otherwise actionable. Moving this issue to v0.13.0 where we should have more data about the performance of gopls' new architecture. |
We encountered a 100% reproducer for this bug in #60089, and were able to understand it: the hanging appears to be client-side, and is related to the size of the file watching patterns gopls was serving to VS Code. It is only reproducible with two saves in short order. We fixed by transposing our watch patterns (more, smaller patterns). |
What version of Go, VS Code & VS Code Go extension are you using?
Version Information
go version
to get version of Go from the VS Code integrated terminal.gopls -v version
to get version of Gopls from the VS Code integrated terminal.code -v
orcode-insiders -v
to get version of VS Code or VS Code Insiders.Go: Locate Configured Go Tools
command.Share the Go related settings you have added/edited
Run
Preferences: Open Settings (JSON)
command to open your settings.json file.Share all the settings with the
go.
or["go"]
orgopls
prefixes.I can't show all, namely directory filters, for work reasons. I have also changed these configuration settings every which way trying to get a viable solution running over the past week. [Below are just snippets in case someone is curious about formatting].
Describe the bug
A clear and concise description of what the bug.
We recently transitioned a very large 70gb+ monorepo from
GOPATH
togo.work
/go.mod
. Use of the language server has definitely been a bumpy transition for local M1 mac devs.On workspace open from configuration file, there is an initial ~1 minute workspace load time (no problem at all, it is a large repo). Once things have loaded, and a specific go file is opened, everything is initially populated great. All inlay hover actions work great, errors are populated if they exist before hand, and even with normal memory mode on, all directory wide errors are populated. You can even make an edit to the code and save once with inlay hovers continuing to work.
However, once you run a second save, there seems to be some cache invalidation as you experience the classic "waiting for code actions from Go" pop-up and inlay hovers just read "loading". After about 2 minutes, the loading/waiting is done and the full code base is completely usable by gopls. Everything is linted as you need it on save, all hover actions work, everything works fine.
This occurs every time you load the workspace. It's almost as if the initial load is populating cache somewhere else or something. Verbose gopls server traces show it's always the second
fixImports
call on save.A couple of findings:
1.) I added quite a bit of logging to the go extensions goMain.js file. In most of the logs, you can see that it completed registering the language provider/document symbols after the hang up ( see the jump from 11:49 to 11:52 in image 1). In others, it reports that the extension host has started profiling the connection and attached the debugger with document symbols returning after a ~1 minute jump (image 2).
This is confirmed every single time this occurs by vs code extension logs reporting something along the lines of the second the hang up occurs:
[2022-07-15 11:22:42.390] [main] [info] Enabling inspect port on extension host with pid 47681
2.) I then switched over to adding a lot of logging to the gopls bin. This reports that it was able to find and return the document symbols in a timely manner.
3.) This identical configuration works perfectly on our linux remote hosts. There is an initial ~1 minute load and then things work great. It seems like it's actually able to call and retrieve the data quick as well. Sometimes there is a momentary hang up with "loading" on hover but the data is returned and hover inlays populated in ~1-2 seconds.
Some thoughts:
1.) Potential culprit is a few
+linux
.go
files we have that are reported when gopls is initial building the workspace. You receive a lot ofNo dep handle found for {+linux file name}
. I have tried to remove these package directories via thebuild.DirectoryFilters
but they are always processed both when the workspace loads and whenfixImports
occurs.When I add a:
or use
test
as the build tag, these errors are not reported but the hang up still occurs.I had a thought that maybe gopls was building these with the linux flag and storing them in modcache as such so have since removed them.
2.) One interesting thing I noticed is sometimes if you completely remove all go tools, modcache, and the go vs code extension, then reinstall them, and load the workspace, things work fine: you have the initial workspace load, traverse to a go file, and things run snappy. This kind of reinforced my thoughts on removing the linux build tag.
3.) I had another hunch that this was potentially dlv related. It doesn't appear as though dlv is available for vscode with an m1, it didn't pop up as an installable tool until I set:
dlv is of course immediately available on our linux builds. When I saw the
Debugger attached
log fromExtension Host
while viewing thegoMain.js
logs, I thought maybe that was dlv attaching itself to gopls. I'm not sure on this one at all, just worth noting.4.) Running
gopls -rpc.trace -v check path/to/file.go
takes about ~30 seconds, performs a full sweep of our go workspace form the looks of it and reports the sameno dep handle for
and c compiler issues. It just runs faster from the looks of it.A clear and concise description of what you expected to happen.
Go through the initial ~1 minute workspace load then have gopls be usable for the entire stack, or at least module, on an M1 mac.
Steps to reproduce the behavior:
Screenshots or recordings
If applicable, add screenshots or recordings to help explain your problem.
The text was updated successfully, but these errors were encountered: