Skip to content
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

Golang uses most of the CPU %, and slows down the windows #280

Closed
AnjanaAK opened this issue Jul 2, 2020 · 4 comments
Closed

Golang uses most of the CPU %, and slows down the windows #280

AnjanaAK opened this issue Jul 2, 2020 · 4 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@AnjanaAK
Copy link

AnjanaAK commented Jul 2, 2020

What version of Go are you using (go version)?

$ go version
go version go1.13.4 linux/amd64

Does this issue reproduce with the latest release?

Didn't tried it yet.

What operating system and processor architecture are you using (go env)?

I am using Windows 10. But we need to work in linux environmens, so also using WSL (Windows subsystem for Linux) .
Same version of go (1.13.4) is installed in both windows and WSL environment.
VS code is installed in Windows. version: 1.46.1.
Only one extension is installed in vscode. That is go extension golang.go with version: 0.15.0.

go env Output
$ go env

GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/Sru/.cache/go-build" GOENV="/home/Sru/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/c/Users/Sru/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build141820206=/tmp/go-build -gno-record-gcc-switches"

What did you do?

As specified, i have vscode instaled in windows with a golang.go extension.

The first issue we found while we working with our golang project in vscode was this:
after some time of using it (nearly 1 hr), the vscode seems to be very slow. Go to definition, saving a file, typing ...etc are very slow. This affects the whole machine and it is very frustrating.

After this, i encountered that :
this issue of slow down also happens when i run go commands via bash (or WSL).
Go tests take much longer time to complete than before.
Another point to note is that other commands like docker doesn't have this problem.
Git commands are affected by this sometimes.

I was able to find a log from vscode:

[2020-07-01 10:12:32.974] [exthost] [error] [ms-vscode.Go] provider FAILED
[2020-07-01 10:12:32.975] [exthost] [error] Error: name must not be falsy
	at Function.validate (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:365:598)
	at new w (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:365:547)
	at new w (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:354:169)
	at c:\Users\Athira\.vscode\extensions\ms-vscode.go-0.14.0\out\src\goOutline.js:117:28
	at Array.forEach (<anonymous>)
	at convertToCodeSymbols (c:\Users\Athira\.vscode\extensions\ms-vscode.go-0.14.0\out\src\goOutline.js:95:19)
	at c:\Users\Athira\.vscode\extensions\ms-vscode.go-0.14.0\out\src\goOutline.js:29:16
	at Generator.next (<anonymous>)
	at fulfilled (c:\Users\Athira\.vscode\extensions\ms-vscode.go-0.14.0\out\src\goOutline.js:9:58)

First i was thinking that this caused the slow behaviour of vscode.
But found same errors in other machines with no speed problems.

Code status result is somewhat like this:

C:\Users\Sru>code --status

Version:          Code 1.46.1 (cd9ea6488829f560dc949a8b2fb789f3cdc05f5d, 2020-06-17T21:13:20.174Z)
OS Version:       Windows_NT x64 10.0.18363
CPUs:             Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz (4 x 2394)
Memory (System):  15.91GB (8.65GB free)
VM:               0%
Screen Reader:    no
Process Argv:
GPU Status:       2d_canvas:                     enabled
                  flash_3d:                      enabled
                  flash_stage3d:                 enabled
                  flash_stage3d_baseline:        enabled
                  gpu_compositing:               enabled
                  multiple_raster_threads:       enabled_on
                  oop_rasterization:             disabled_off
                  protected_video_decode:        unavailable_off
                  rasterization:                 enabled
                  skia_renderer:                 disabled_off_ok
                  video_decode:                  enabled
                  viz_display_compositor:        enabled_on
                  viz_hit_test_surface_layer:    disabled_off_ok
                  webgl:                         enabled
                  webgl2:                        enabled

CPU %   Mem MB     PID  Process
    0       95   19484  code main
    0      166    2008     gpu-process
    0       77    6152     shared-process
    0       28   14096     utility
    0       14   17768     electron-crash-reporter
    0      242   24336     window (query_test.go - Untitled (Workspace) - Visual Studio Code)
    0        5    1912       console-window-host (Windows internal process)
    0       34    2528       searchService
    0       34    7076       watcherService
    0        5    8532       console-window-host (Windows internal process)
    0        5   18760       C:\WINDOWS\System32\wsl.exe
    0        5   22652         C:\WINDOWS\System32\lxss\wslhost.exe {6cec54c6-edf5-47bb-849b-5790e4948205} 464 472 476
    0       12   23136           console-window-host (Windows internal process)
    0       97   24944       extensionHost
    0       29   27984         "C:\Program Files\Microsoft VS Code\Code.exe" "c:\Program Files\Microsoft VS Code\resources\app\extensions\json-language-features\server\dist\jsonServerMain" --node-ipc --clientProcessId=24944
    0       61   26320       C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe

Workspace Stats:
|  Window (query_test.go - Untitled (Workspace) - Visual Studio Code)
|    Folder (dynatypes): 290 files
|      File types: go(289) out(1)
|      Conf files:
|    Folder (actionindex): 126 files
|      File types: go(97) out(6) test(4) template(4) yml(2) xlsx(2) docx(1)
|                  go_fl(1) txt(1)
|      Conf files:

Windows task manager says the CPU % of processes in two cases:

  1. While using VScode (using go to definition and all) :
    ( It was displaying that total 100% CPU is used).
        Process  &  CPU % used by the process    
       -------------------------------------------
          go   =>  54.7%       
          git for windows =>  24.6% 
          godef  => 23.1%
          task manager => 11.9 %
          Anti Malware service executable  => 34.2%
  1. While running go test command in WSL:
    ( It was displaying that total 100% CPU is used).
        Process          CPU % used by the process     Power usage
       ---------------------------------------------------------------
          go                   80.5%                     very high

What did you tried?

  1. Tried changing the power plan of windows from 'balanced' to 'high perfomance' mode.
    This didn't fixed the problem.

  2. Tried reinstalling the VScode with latest version, and thus extension also.
    Still the issue persists.

  3. Tried disabling the onsave features, autosave features in vscode.
    This made a little difference (not fixed) in the speed while using VScode. But problem with bash is still there.

What did you expect to see?

A less cpu % should be used by the go and slowness in the machine should be less.

What did you see instead?

I can see 100% total CPU usage while running a go test in the WSL of windows, or while using the vscode.

@stamblerre stamblerre transferred this issue from golang/go Jul 2, 2020
@stamblerre
Copy link
Contributor

stamblerre commented Jul 2, 2020

Transferred this to the vscode-go repo since it seems to be pretty tied to VS Code. Perhaps we can open a new issue in the golang/go repository if we find an issue that can be isolated to the go command.

@AnjanaAK: Can you please share your VS Code Settings? They can be found by going to the Command Palette (Ctrl+Shift+P) -> Preferences: Open Settings (JSON).

@hyangah hyangah added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jul 4, 2020
@AnjanaAK
Copy link
Author

AnjanaAK commented Jul 6, 2020

Transferred this to the vscode-go repo since it seems to be pretty tied to VS Code. Perhaps we can open a new issue in the golang/go repository if we find an issue that can be isolated to the go command.

@AnjanaAK: Can you please share your VS Code Settings? They can be found by going to the Command Palette (Ctrl+Shift+P) -> Preferences: Open Settings (JSON).

@stamblerre If it is a problem with vscode, then why it still exists while running go commands in command prompt?
I'm sharing my vscode settings here:

{
    "window.zoomLevel": -1,
    "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\wsl.exe"
}

@hyangah
Copy link
Contributor

hyangah commented Jul 6, 2020

@AnjanaAK Thanks for sharing the settings.

The go command is a collection of subcommands (compile, link, test, list, vet, ...) and the vscode go extension and its underlying tools (including godef) call it for various tasks. So, the aggregated cpu usage does not tell us much.

The first step should be to figure out what subcommand of go is running. Can you capture the full arguments and per-process cpu usage?

Also, you mentioned go test is using 100% of cpu. Can you tell us more about the tests? If it's CPU intensive and highly parallelized, 100% cpu usage is working as intended.

@stamblerre
Copy link
Contributor

There has been no activity on this issue for a few months, so going to close this.
@AnjanaAK: Please open a new issue if you encounter this again.

@golang golang locked and limited conversation to collaborators Nov 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants