Open malkhamis opened 5 years ago
I'm having the same problem on a new macbook. Typing too quickly causes atom to slow down significantly. Saving a file causes 100% CPU utilization for 5-60 seconds, freezing up not just Atom, but my entire computer. Unfortunately it's making go-plus completely unusable.
Looking at CPU usage, the lag looks to be coming from gosec
Sort of fixed the issue by switching the default linter to golangci-lint (why is this not the default now?) and adding the --fast
flag to it.
@charlesbwork I am already using golangci-lint
and I just tried to use flag --fast
.. It seems that it made saving files faster, but that didn't resolve the keystroke lagging for me :(
Its almost certainly autocomplete that is slowing things down for you and not linters.
Based on the output above, you are working in a module (GOMOD
is set, and your project is not inside GOPATH
). gocode
does not work well with modules. We'll have support for completions via the gopls
language server out soon, which will speed things up significantly when working with modules.
For now, you can try using github.com/stamblerre/gocode
or moving your code into GOPATH.
@zmb3 thanks for your response.. I indicated in a separate thread that I already use stamblerre/gocode
:)
@zmb3 I'm still experiencing the extreme typing lag and slow save times while working within my GOPATH (not using GOMOD).
go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/.../Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/.../go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11.5/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11.5/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/w5/k2yzbggn4b7djqwm2g5yc87dhp8bvx/T/go-build853182707=/tmp/go-build -gno-record-gcc-switches -fno-common"
@zmb3 , having partially the same symptons as described above, just autocomplete is very slow and cpu peaks to 100%, but saving files is quick.
I'm using stamblerre/gocode
.
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/fernando/.cache/go-build"
GOENV="/home/fernando/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/fernando/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-build779961285=/tmp/go-build -gno-record-gcc-switches"
Prerequisites
atom .
from the terminal in your project's directory?go env
is correct? If it is, please include the output in this issue.Description
Atom becomes overwhelmingly slow and it eats all my CPU resources by simply typing fast in a repository/project that has a large code base. That is, it takes a couple of seconds for my editor to catch up with the keyboard input stream. During that time, Atom freezes and becomes unusable. Disabling
go-plus
solves the problem. After doing some profiling, it seems that the following function call is causing the slow-down:executeGocode
in filegocodeprovider.js #337
. The problem for me is that for each key stroke,go-plus
spawns a child process that invokesgocode
and as I type, more child processes than what my CPUs can cope with are spawned.I could be wrong with my analysis as I didn't really dive deep into it, but I thought I should file an issue here. It should be noted the above is more on the side of a non-issue if the repository I am working in has a relatively small code base.
Output from
atom -v && apm -v
Output From
go env
GOARCH="amd64" GOBIN="" GOCACHE="/home/malkhamis/.cache/go-build" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/malkhamis/go" GOPROXY="" GORACE="" GOROOT="/usr/lib/golang" GOTMPDIR="" GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64" GCCGO="gccgo" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home/malkhamis/src/github.com/[org]/[repo]/go.mod" 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-build354973049=/tmp/go-build -gno-record-gcc-switches"
Steps to Reproduce
Depending on the platform/machine used, these steps may or may not reproduce the problem:
Expected Behavior
1) Atom should not freeze 2) I should get auto-completion suggestions in a timely manner 3) My CPU usage shouldn't reach 100% 4) the editor should not lag behind my keyboard strokes
Actual Behavior
Atom freezes and editor lags behind keyboard input stream until all gocode child processes finish
Helpful Information
CPU: Intel(R) Xeon(R) CPU E3-1241 v3 @ 3.50GHz (4 physical cores, 8 threads) Hard Disk type: SSD Free Memory: 7.5 GB