vscode-go
vscode-go copied to clipboard
High CPU Usage
What version of Go, VS Code & VS Code Go extension are you using?
Version Information
- Run
go versionto get version of Go from the VS Code integrated terminal.- go version go1.19.5 windows/amd64
- Run
gopls -v versionto get version of Gopls from the VS Code integrated terminal.- Build info
golang.org/x/tools/gopls v0.11.0 golang.org/x/tools/[email protected] h1:/nvKHdTtePQmrv9XN3gIUN9MOdUrKzO/dcqgbG6x8EY= github.com/BurntSushi/[email protected] h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= github.com/google/[email protected] h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/sergi/[email protected] h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= golang.org/x/[email protected] h1:QfTh0HpN6hlw6D3vu8DAwC8pBIwikq0AI1evdm+FksE= golang.org/x/exp/[email protected] h1:fl8k2zg28yA23264d82M4dp+YlJ3ngDcpuB1bewkQi4= golang.org/x/[email protected] h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA= golang.org/x/[email protected] h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= golang.org/x/[email protected] h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= golang.org/x/[email protected] h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= golang.org/x/[email protected] h1:7/HkGkN/2ktghBCSRRgp31wAww4syfsW52tj7yirjWk= golang.org/x/[email protected] h1:qptQiQwEpETwDiz85LKtChqif9xhVkAm8Nhxs0xnTww= honnef.co/go/[email protected] h1:oDx7VAwstgpYpb3wv0oxiZlxY+foCpRAwY7Vk6XpAgA= mvdan.cc/[email protected] h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM= mvdan.cc/xurls/[email protected] h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc= go: go1.19.1
-
Run
code -vorcode-insiders -vto get version of VS Code or VS Code Insiders.- 1.75.0-insider 9ccc2b3b30c122afe45bc6722bef0e3901fb2806 x64
-
Check your installed extensions to get the version of the VS Code Go extension
-
-
Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) >
Go: Locate Configured Go Toolscommand.- Checking configured tools.... GOBIN: G:\code/bin toolsGopath: gopath: C:\Users\qinxurui\go GOROOT: G:\go PATH: G:\go\bin;C:\Program Files\Common Files\Oracle\Java\javapath;G:\py3.10\Scripts;G:\py3.10;C:\Program Files\PlasticSCM5\server;C:\Program Files\PlasticSCM5\client;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\ia32\compiler;C:\Program Files\AdoptOpenJDK\jdk-11.0.11.9-hotspot\bin;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64_win\compiler;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Program Files (x86)\Hyenae;C:\Program Files (x86)\NetSarang\Xshell 7;C:\Program Files (x86)\NetSarang\Xftp 7;C:\Program Files\python;C:\Program Files\python\Scripts;G:\BtSoft\panel\script;C:\Program Files (x86)\Paragon Software\ExtFS for Windows;G:\code;G:\code/bin;C:\Program Files (x86)\QuickTime\QTSystem;C:\Program Files\Docker\Docker\resources\bin;C:\ProgramData\DockerDesktop\version-bin;G:\Git\cmd;G:\npmdl\npm\global;G:\flutter\bin;G:\androidsdk\platform-tools;C:\Program Files\python;C:\Program Files\python\Scripts;G:\BtSoft\panel\script;D:\Program Files (x86)\IncrediBuild;C:\ProgramData\chocolatey\bin;G:\nodejs16;C:\Users\qinxurui.cargo\bin;C:\Users\qinxurui\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Program Files\Bandizip;C:\Users\qinxurui\AppData\Local\Programs\Fiddler;C:\Program Files (x86)\Fiddler;C:\Users\qinxurui\AppData\Local\Microsoft\WindowsApps;C:\Users\qinxurui\AppData\Local\GitHubDesktop\bin;C:\Users\qinxurui\go\bin;%ANDROID_SDK_ROOT%\platform-tools;%ANDROID_SDK_ROOT%\emulator;%ANDROID_SDK_ROOT%\tools;%ANDROID_SDK_ROOT%\tools\bin;G:\npmdl\npm\global;G:\flutter\bin;G:\androidsdk\platform-tools;G:\fidder\Fiddler;C:\Users\qinxurui\go\bin;G:\fidderclassic\Fiddler;G:\flutter.pub-cache\bin;C:\Users\qinxurui\AppData\Roaming\npm;G:\Microsoft VS Code Insiders\bin;G:\Microsoft VS Code\bin;C:\Users\qinxurui\go\bin PATH (vscode launched with): C:\Program Files\Common Files\Oracle\Java\javapath;G:\py3.10\Scripts;G:\py3.10;C:\Program Files\PlasticSCM5\server;C:\Program Files\PlasticSCM5\client;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\ia32\compiler;C:\Program Files\AdoptOpenJDK\jdk-11.0.11.9-hotspot\bin;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64_win\compiler;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Program Files (x86)\Hyenae;C:\Program Files (x86)\NetSarang\Xshell 7;C:\Program Files (x86)\NetSarang\Xftp 7;C:\Program Files\python;C:\Program Files\python\Scripts;G:\BtSoft\panel\script;C:\Program Files (x86)\Paragon Software\ExtFS for Windows;G:\code;G:\code/bin;G:\go\bin;C:\Program Files (x86)\QuickTime\QTSystem;C:\Program Files\Docker\Docker\resources\bin;C:\ProgramData\DockerDesktop\version-bin;G:\Git\cmd;G:\npmdl\npm\global;G:\flutter\bin;G:\androidsdk\platform-tools;C:\Program Files\python;C:\Program Files\python\Scripts;G:\BtSoft\panel\script;D:\Program Files (x86)\IncrediBuild;C:\ProgramData\chocolatey\bin;G:\nodejs16;G:\go\bin;C:\Users\qinxurui.cargo\bin;C:\Users\qinxurui\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Program Files\Bandizip;C:\Users\qinxurui\AppData\Local\Programs\Fiddler;C:\Program Files (x86)\Fiddler;C:\Users\qinxurui\AppData\Local\Microsoft\WindowsApps;C:\Users\qinxurui\AppData\Local\GitHubDesktop\bin;C:\Users\qinxurui\go\bin;%ANDROID_SDK_ROOT%\platform-tools;%ANDROID_SDK_ROOT%\emulator;%ANDROID_SDK_ROOT%\tools;%ANDROID_SDK_ROOT%\tools\bin;G:\npmdl\npm\global;G:\flutter\bin;G:\androidsdk\platform-tools;G:\fidder\Fiddler;C:\Users\qinxurui\go\bin;G:\fidderclassic\Fiddler;G:\flutter.pub-cache\bin;C:\Users\qinxurui\AppData\Roaming\npm;G:\Microsoft VS Code Insiders\bin;G:\Microsoft VS Code\bin;C:\Users\qinxurui\go\bin
go: G:\go\bin\go.exe: go version go1.19.5 windows/amd64
gotests: G:\code\bin\gotests.exe (version: v1.6.0 built with go: go1.19.1) gomodifytags: G:\code\bin\gomodifytags.exe (version: v1.16.0 built with go: go1.19.1) impl: G:\code\bin\impl.exe (version: v1.1.0 built with go: go1.19.1) goplay: G:\code\bin\goplay.exe (version: v1.0.0 built with go: go1.19.1) dlv: G:\code\bin\dlv.exe (version: v1.9.1 built with go: go1.19.1) staticcheck: G:\code\bin\staticcheck.exe (version: v0.3.3 built with go: go1.19.1) gopls: G:\code\bin\gopls.exe (version: v0.11.0 built with go: go1.19.1)
go env Workspace Folder (daqiaohancai): g:\code\project\daqiaohancai set GO111MODULE=on set GOARCH=amd64 set GOBIN=G:\code/bin set GOCACHE=C:\Users\qinxurui\AppData\Local\go-build set GOENV=C:\Users\qinxurui\AppData\Roaming\go\env set GOEXE=.exe set GOEXPERIMENT= set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOINSECURE= set GOMODCACHE=C:\Users\qinxurui\go\pkg\mod set GONOPROXY=**.baidu.com** set GONOSUMDB=* set GOOS=windows set GOPATH=C:\Users\qinxurui\go set GOPRIVATE= set GOPROXY=https://goproxy.cn,direct set GOROOT=G:\go set GOSUMDB=sum.golang.org set GOTMPDIR= set GOTOOLDIR=G:\go\pkg\tool\windows_amd64 set GOVCS= set GOVERSION=go1.19.5 set GCCGO=gccgo set GOAMD64=v1 set AR=ar set CC=gcc set CXX=g++ set CGO_ENABLED=0 set GOMOD=NUL set GOWORK= set CGO_CFLAGS=-g -O2 set CGO_CPPFLAGS= set CGO_CXXFLAGS=-g -O2 set CGO_FFLAGS=-g -O2 set CGO_LDFLAGS=-g -O2 set PKG_CONFIG=pkg-config set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\qinxurui\AppData\Local\Temp\go-build1008291301=/tmp/go-build -gno-record-gcc-switches
Share the Go related settings you have added/edited
i have no "setting
Describe the bug
when i use vscode go plugin my computer's cpu usage will Intermittent high,please unzip and watch the video 2023-01-22 20-48-33.zip
please unzip the zip to get the cpuprofile CPU-20230122T203309.cpuprofile.zip
Hi, gopls does use a lot of CPU. We're working on fixing that, but without more info about your particular use-case, I'm not sure this issue is actionable.
Can you share approximately how large your workspace is, in terms of number of files?


that's all,just a mini proj :(
Are you seeing persistent CPU usage, or just at startup? When gopls starts, it type-checks the workspace (which may involve type-checking dependencies, and can be expensive if there are a lot of large dependencies). But eventually it should stabilize and not use that much CPU.
Whenever I press ctrl+s, CPU usage becomes 100% And last 2 s , you can watch the video https://github.com/golang/vscode-go/files/10474450/2023-01-22.20-48-33.zip
Are you able to capture extension logs? https://github.com/golang/vscode-go/blob/master/docs/troubleshooting.md#collect-extension-logs
That would tell us what gopls is doing. (note: these logs can contain source code, so be careful if you don't want to share file content)
Are you able to capture extension logs? https://github.com/golang/vscode-go/blob/master/docs/troubleshooting.md#collect-extension-logs
That would tell us what gopls is doing. (note: these logs can contain source code, so be careful if you don't want to share file content)
sorry i cant find the options , my vscode inside is chinese and the view output js grey
Sorry, it's going to be very difficult for us to diagnose without more info.
I can try to take a look at your CPU profile -- how did you collect it?
golang/go#57987 is our medium-term project to drastically improve performance.
Sorry, it's going to be very difficult for us to diagnose without more info.
I can try to take a look at your CPU profile -- how did you collect it?
golang/go#57987 is our medium-term project to drastically improve performance.
i use the devtools to collect it when i coding the go
Sorry, it's going to be very difficult for us to diagnose without more info.
I can try to take a look at your CPU profile -- how did you collect it?
golang/go#57987 is our medium-term project to drastically improve performance.
i check my taskmanager , infact the gopls.exe CPU usage is not very high , almost 15% , the vscode‘s’ all process cpu usage is 30% or so , but the system.exe is 30+% , the total cpu usage is 100% , my computer‘s cpu is i7-8750h 6c12t 3.9ghz 16gmem
Oh that's interesting context, thank you. We'll discuss this in our triage meeting.
Do you have any other extensions active that could cause this?
no,just use vetur and dart/flutter and go
Unfortunately the attached CPU profile shows only the VS Code workbench side samples (not the shared process where this extension code is running). I see a lot of executeCommand calls, so I have wild guess but extension profile will be helpful before making any conclusion.
@dbstd2333 Can you try to collect the extension profile following https://github.com/microsoft/vscode/wiki/Performance-Issues#profile-the-running-extensions? And try "Developer: Open Process Explorer" - that will show what sub processes of vscode are consuming cpu/memory.
I get very high CPU usage whenever I save from the linting tools I have configured to run. @dbstd2333 is it possible you're seeing the same thing?
I just want an IDE that works., and doesn't get in the way of my programming by creating artificial constraints and making my laptop super hot from high CPU usage, as I'm only typing text.
From my perspective, I'm just using a fancy version of notepad, and there is no reason for a single EXE that I consider optional and only needed every 30 seconds or so to be called on every single thing I type. That's just insane.
Please, the integration with GOPLS needs to change, so it's not as CPU heavy. It's simply called too often by Visual Studio Code when it should not be, its not caching files that do not change in memory enough, its doing too much disk IO Unnecessarily and wastefully, and its become an actively harmful thing to the Go community; I'm sick of losing laptops because they overheat due to this issue. This bad code is killing hardware, PLEASE FIX IT.
@duaneking please keep in mind the Go code of conduct in your communication. We don't want you to have a poor user experience, and work with our limited resources to address the most important problems or missing features our users encounter with gopls and the VS Code plugin.
For example, [email protected] significantly reduced gopls' memory footprint, which was a major pain point for many users. That change required a redesign of gopls' core operations. We aimed to achieve similar performance with a fraction of the memory, and for the most part achieved that goal. However, there are certain areas where we may have regressed, and we have been fixing these regressions as we discover them; many are edge cases related to the new analysis driver which for the first time fully analyzes dependencies (for example golang/go#61178).
Additionally, I think there are opportunities to reduce CPU across the board while typing. I'm working on this now in golang/go#60926.
If you're having specific problems, the best way to help us fix them is by helping us investigate: how large is your workspace? Can you share the output of gopls stats -anon? Did you experience these problems with [email protected], or just [email protected]? What exactly do you observe? Would you be willing to capture a CPU profile while you're typing?
Alternatively, you can disable language server integration entirely with the "go.useLanguageServer" setting.
Macbook pro m1
When i turn on vscode go plugin i have 400% of usage cpu
Cpu have over 1000C temperature. Will u fix this problem?
@Zrossiz how long does it take for the CPU to settle to 0%? The first time you use gopls on a workspace, it must do a significant amount of indexing.
@findleyr its allways 400% usage of cpu. It doesn't get any less with time.
@findleyr i have this problem like 2 days. Before this plugin working normally
I want add that I also notice high CPU usage for this plugin. Im running mine on linux wayland. Process explorer does not show anything golang plugin related. When I open KDE activity monitor, the CPU is pegged. After I removed the golang plugin from VS Code the CPU went back to normal.
I have a very small test/ sample project that has basically one dependency.