vscode-go icon indicating copy to clipboard operation
vscode-go copied to clipboard

Extension causes high cpu load

Open Hong-Swinburne opened this issue 4 years ago • 8 comments

EDIT by @hyangah:

If VSCode's automated issue report sent you here, please open a new issue to discuss your case:

  • Fill out the issue template
  • Attach golang.go-unresponsive.cpuprofile.txt VS Code left on your home-directory. (if curious, try to follow https://github.com/microsoft/vscode/wiki/Explain-extension-causes-high-cpu-load to visualize the profile :-))
  • Read the troubleshooting guide.
  • Check "Developer: Open Process Explorer" and see if there are processes with excessive cpu/memory usage.

  • Issue Type: Performance
  • Extension Name: go
  • Extension Version: 0.28.1
  • OS Version: Windows_NT x64 10.0.19042
  • VS Code version: 1.60.2

:warning: Make sure to attach this file from your home-directory: :warning:c:\Users\HONGPA~1\AppData\Local\Temp\golang.go-unresponsive.cpuprofile.txt

Find more details here: https://github.com/microsoft/vscode/wiki/Explain-extension-causes-high-cpu-load

Hong-Swinburne avatar Oct 06 '21 01:10 Hong-Swinburne

Thanks for the report @Hong-Swinburne Please attach this file from your home-directory: c:\Users\HONGPA~1\AppData\Local\Temp\golang.go-unresponsive.cpuprofile.txt.

hyangah avatar Oct 06 '21 11:10 hyangah

  • Issue Type: Performance
  • Extension Name: go
  • Extension Version: 0.28.1
  • OS Version: Darwin x64 20.6.0
  • VS Code version: 1.61.2

golang.go-unresponsive.cpuprofile.txt

hmert avatar Oct 19 '21 22:10 hmert

I have same issue golang.go-unresponsive.cpuprofile.txt

wolf99 avatar Nov 08 '21 15:11 wolf99

Something in gopls seemed stuck to me; I SIGTERMed it and everything came good; There doesn't seem to be anything in the profile about go itself, only js, so I haven't attached my profile

rbtcollins avatar Nov 24 '21 09:11 rbtcollins

I have the same issue, whenever trying to edit and save a go file in VS Code. Always hiccupping. I'm surprised why this issue hasn't been deal with yet up until now?! Bad performance makes an extension useless regardless how many cool features it might have. I was trying to learn Go out of curiosity, sticking only with VS Code, so because of this extension got discouraged and moved on.

MatinSasan avatar May 13 '22 01:05 MatinSasan

Thanks for attaching the cpuprofiles @hmert and @wolf99 (and sorry for the delay)

  • @hmert - the profile shows test explorer logic repeatedly ran updateGoTestContext. Not sure what caused that behavior. If this is still an issue, maybe try to disable text explorer to see that helps. (go.testExplorer.enable setting).
  • @wolf99 - the profile shows repeated execution of runGoModEnv - there are many code paths that lead to it, so sharing settings.json may help.

As @rbtcollins said, however, it's possible that the problem can be gopls.

@MatinSasan there are many different underlying causes for high-cpu load. Without details of the problem, it's not actionable. If you are experiencing slowness related to edit/save, my guess is gopls is struggling. Please open a new issue to describe your specific case - fill out the details for the questions in the template, and also follow the troubleshooting guide.

hyangah avatar May 13 '22 03:05 hyangah

Sorry, I don't have the extension installed any more. Have even switched laptops since then 😄

wolf99 avatar May 14 '22 16:05 wolf99

I have a similar issue in Windows. When it happens, every time i save a .go file, vscode and Windows Defender will consume high CPU for several seconds. If ^S multiple times this can last for a minute. I tried adding folders to the exclusion list of WInDefend, including %GOTMPDIR%, my workspace, c:\ProgramData\Microsoft\Windows Defender, code.exe, go.exe, gopls.exe, staticcheck.exe, but none works. It really hits productivity.

szmcdull avatar Jun 11 '22 04:06 szmcdull

For me it happens when I add a new import to a new/existing file.

It takes around 3-5s until it re-builds the cache. During this period no completions are available and the CPU is at 100% on all cores.

After this period the CPU goes back to normal and the completions are working as expected.

I noticed the same behavior in neovim, so it seems to be related to the way the language server updates the project structure and not to the editor extension.

mihai-vlc avatar Dec 22 '22 19:12 mihai-vlc

@mihai-vlc For gopls performance issue, I think it's better to track separately. Do you mind filing a separate issue for gopls? Would be nice if you can share a repro case. If not possible, another way is to watching the process list and capturing a cpu profile of gopls when that happens.

@szmcdull Sorry for the late reply - when this happens or when you are able to reproduce the issue, can you open "Developer: Open Process Explorer" and check what process is consuming the CPU?

hyangah avatar Jan 05 '23 16:01 hyangah

@szmcdull Sorry for the late reply - when this happens or when you are able to reproduce the issue, can you open "Developer: Open Process Explorer" and check what process is consuming the CPU?

MsMpEng.exe (Windows Defender): 18% Code.exe     multiple staticcheck.exe         multiple go list: 0.1%-15% each     multiple cmd.exe         conhost.exe         taskkill.exe WmiPrvSE.exe (WMI Provider Host): 12% Code.exe (code-spell-checker extension): 5% multiple other Code.exe: hard to count

szmcdull avatar Jan 06 '23 03:01 szmcdull

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

gopherbot avatar Feb 05 '23 16:02 gopherbot