golang / vscode-go

Go extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=golang.Go
Other
3.86k stars 741 forks source link

slow search - when go plugin installed, the search funtionality of vs code become unusable in large projects. #3355

Closed EdgarLip closed 5 months ago

EdgarLip commented 5 months ago

$ go version go version go1.22.1 windows/amd64

vs code: Version: 1.88.1 (user setup) Commit: e170252f762678dec6ca2cc69aba1570769a5d39 Date: 2024-04-10T17:41:02.734Z Electron: 28.2.8 ElectronBuildId: 27744544 Chromium: 120.0.6099.291 Node.js: 18.18.2 V8: 12.0.267.19-electron.0 OS: Windows_NT x64 10.0.19044

$ gopls -v version Build info

golang.org/x/tools/gopls v0.15.3 golang.org/x/tools/gopls@v0.15.3 h1:zbdOidFrPTc8Bx0YrN5QKgJ0zCjyGi0L27sKQ/bDG5o= github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= github.com/google/go-cmp@v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y= golang.org/x/mod@v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= golang.org/x/sync@v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= golang.org/x/sys@v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= golang.org/x/telemetry@v0.0.0-20240209200032-7b892fcb8a78 h1:vcVnuftN4J4UKLRcgetjzfU9FjjgXUUYUc3JhFplgV4=
golang.org/x/text@v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/tools@v0.18.1-0.20240412183611-d92ae0781217 h1:uH9jJYgeLCvblH0S+03kFO0qUDxRkbLRLFiKVVDl7ak=
golang.org/x/vuln@v1.0.1 h1:KUas02EjQK5LTuIx1OylBQdKKZ9jeugs+HiqO5HormU= honnef.co/go/tools@v0.4.6 h1:oFEHCKeID7to/3autwsWfnuv69j3NsfcXbvJKuIcep8= mvdan.cc/gofumpt@v0.6.0 h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo= mvdan.cc/xurls/v2@v2.5.0 h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8= go: go1.22.1

$ code -v 1.88.1 e170252f762678dec6ca2cc69aba1570769a5d39 x64

setting: ( the only thing that it is related to go that i have found) 1) // If this setting is false, no telemetry will be sent regardless of the new setting's value. Deprecated in favor of the telemetry.telemetryLevel setting. // Enable diagnostic data to be collected. This helps us to better understand how Visual Studio Code is performing and where improvements need to be made. Read more about what we collect and our privacy statement. "telemetry.enableTelemetry": true,

"go.alternateTools": {
                                                      < ------ this is empty ....  C:\Users\<my name>\AppData\Roaming\Code\User\settings.json
}

golang.go

Describe the bug

The bug : 1) installing the the go addon. 2) ctr + shift+f 3) seach for some thing e.g: "copy system clock" it can take few minutes

A clear and concise description of what you expected to happen. 1)expect it to find it under 3 seconds ! which is what happends when i remove the go plugin and restart.

image this seach can take more then 3 minutes - which is unacceptable, when without the plugin it take 3 seconds max.

hyangah commented 5 months ago

@EdgarLip Since the "Search" functionality does not directly interact with this extension or its tools, we need more info for triage.

EdgarLip commented 5 months ago

Hi @hyangah thanks for taking this one !

• here is a snippet of the process explorer during very long search : image

• added the flag: image restarted few times "vscode" ... but i do not see the 'gopls (server)' in the drop down list.

•added go to be allowed by the FW: image again restart everything just in case ... no change... i do not know how to add gopls.

hyangah commented 5 months ago

Thanks for sharing the screenshots. I don't see anything obvious unfortunately. From the process explorer, I guess extensionHost[3] is the one corresponding to the window with go files since that's the only one with gopls process. That process and its children consumes 0% of CPU. Memory usage is also not too high. In fact, other VS Code processes seem also idle.

Screenshot 2024-04-23 at 1 26 58 PM
EdgarLip commented 5 months ago

1)i have successfully added the gopls to the FW exceptions as well : which in my case located : C:\Users\\go\bin\gopls.exe image

2) i have disable and even uninstalled all plugins , and even when go is the only one installed - this is happening. i will not recreate it right now to show ... since it took so much of my time.

3) here is how the search looks like for the windows task explorer, during search is running: image

4) after playing long time with the searches and with the task explorer ( and after excluding the gopls - from the FW as mentioned above ), it looks the issue is now not persistent as was previously, but happens only when "microsoft defender antibvirus service" service is at it's peak ( don't know what it's doing ) image then search is slow.

5) regarding gopls traces: image still can not see it ...

hyangah commented 5 months ago

Thanks for the detailed info and screenshot.

it looks the issue is now not persistent as was previously, but happens only when "microsoft defender antibvirus service" service is at it's peak

It looks like the issue is the Antivirus software.

Microsoft Defender Antivirus Service is the anti-virus software. I don't know exactly what it is doing, but there are many reports in the internet that talk about slowness caused by Microsoft Defender. See https://groups.google.com/g/golang-nuts/c/IR8v3B1pPCI/m/-yrCL_j0HAAJhttps://groups.google.com/g/golang-nuts/c/IR8v3B1pPCI/m/-yrCL_j0HAAJ

Try to adjust exclusion rules to skip files in the directories used by the go command and gopls:

https://support.microsoft.com/en-us/windows/add-an-exclusion-to-windows-security-811816c0-4dfd-af4a-47e4-c301afe13b26 or https://www.dell.com/support/kbdoc/en-us/000128249/windows-defender-resolving-high-hard-disk-drive-and-cpu-usage-during-scans

For example, configure the anti-virus scanner to skip directories reported by go env GOMODCACHE GOBUILDCACHE and the CacheDir directory reported by gopls.exe stats.

Since the issue is not the extension's issue but requires the antivirus software configuration, I will close the issue.