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

Increased memory usage in 1.24.0 causing out-of-memory #994

Closed
3 tasks done
invidian opened this issue Mar 15, 2020 · 16 comments
Closed
3 tasks done

Increased memory usage in 1.24.0 causing out-of-memory #994

invidian opened this issue Mar 15, 2020 · 16 comments
Labels
cursed This issue is doomed. topic: memory Huge memory consumption

Comments

@invidian
Copy link
Contributor

It seems that after upgrading golangci-lint for my project to 1.24.0, Travis CI is no longer able to lint the project, as it fails with out-of-memory errors: https://travis-ci.org/github/flexkube/libflexkube/jobs/662847029#L1086

After reverting the same PR to 1.23.8, linting passes: https://travis-ci.org/github/flexkube/libflexkube/jobs/662848310?utm_medium=notification&utm_source=github_status.

PR affected by the issue: flexkube/libflexkube#82

Offending patch (now reverted):

diff --git Makefile Makefile
index bb0b33c..caa47b4 100644
--- Makefile
+++ Makefile
@@ -11,7 +11,7 @@ GORUN=$(GOCMD) run
 GOBUILD=CGO_ENABLED=$(CGO_ENABLED) $(GOCMD) build -v -buildmode=exe -ldflags $(LD_FLAGS)
 
 CC_TEST_REPORTER_ID=6e107e510c5479f40b0ce9166a254f3f1ee0bc547b3e48281bada1a5a32bb56d
-GOLANGCI_LINT_VERSION=v1.23.8
+GOLANGCI_LINT_VERSION=v1.24.0
 BIN_PATH=$$HOME/bin
 
 GO_PACKAGES=./...

Thank you for creating the issue!

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc).

Please include the following information:

Version of golangci-lint
$ golangci-lint --version
golangci-lint has version 1.24.0 built from 6fd4383 on 2020-03-15T11:38:02Z
Config file
$ cat .golangci.yml
cat: .golangci.yml: No such file or directory```

</details>

<details><summary>Go environment</summary>

```console
$ go version && go env
go version go1.14 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/invidian/.cache/go-build"
GOENV="/home/invidian/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/invidian/go"
GOPRIVATE=""
GOPROXY="http://localhost:8081,https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/invidian/repos/libflexkube/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-build666784723=/tmp/go-build -gno-record-gcc-switches"
Verbose output of running
$ golangci-lint run --enable-all --disable=godox,lll,funlen --max-same-issues=0 --max-issues-per-linter=0 --build-tags integration --timeout 10m --exclude-use-default=false ./... -v
INFO [config_reader] Config search paths: [./ /home/invidian/repos/libflexkube/integration /home/invidian/repos/libflexkube /home/invidian/repos /home/invidian /home /] 
INFO [lintersdb] Active 38 linters: [bodyclose deadcode depguard dogsled dupl errcheck gochecknoglobals gochecknoinits gocognit goconst gocritic gocyclo gofmt goimports golint gomnd goprintffuncname gosec gosimple govet ineffassign interfacer maligned misspell nakedret prealloc rowserrcheck scopelint staticcheck structcheck stylecheck typecheck unconvert unparam unused varcheck whitespace wsl] 
INFO [lintersdb] Active 38 linters: [bodyclose deadcode depguard dogsled dupl errcheck gochecknoglobals gochecknoinits gocognit goconst gocritic gocyclo gofmt goimports golint gomnd goprintffuncname gosec gosimple govet ineffassign interfacer maligned misspell nakedret prealloc rowserrcheck scopelint staticcheck structcheck stylecheck typecheck unconvert unparam unused varcheck whitespace wsl] 
INFO [loader] Go packages loading at mode 575 (compiled_files|exports_file|files|imports|name|deps|types_sizes) took 607.943833ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 5.466128ms 
INFO [runner/unused/goanalysis] analyzers took 0s with no stages 
INFO [runner/goanalysis_metalinter/goanalysis] analyzers took 0s with no stages 
INFO [runner] Issues before processing: 12, after processing: 0 
INFO [runner] Processors filtering stat (out/in): filename_unadjuster: 12/12, path_prettifier: 12/12, skip_files: 12/12, autogenerated_exclude: 12/12, exclude-rules: 12/12, nolint: 0/12, skip_dirs: 12/12, cgo: 12/12, identifier_marker: 12/12, exclude: 12/12 
INFO [runner] processing took 6.995723ms with stages: nolint: 6.544171ms, identifier_marker: 206.175µs, path_prettifier: 120.378µs, autogenerated_exclude: 65.971µs, skip_dirs: 44.667µs, cgo: 4.006µs, max_same_issues: 3.183µs, uniq_by_line: 1.573µs, filename_unadjuster: 1.453µs, max_from_linter: 1.038µs, diff: 984ns, skip_files: 677ns, source_code: 435ns, path_shortener: 415ns, max_per_file_from_linter: 225ns, exclude: 198ns, exclude-rules: 174ns 
INFO [runner] linters took 238.006384ms with stages: unused: 219.300356ms, goanalysis_metalinter: 11.516494ms 
INFO File cache stats: 0 entries of total size 0B 
INFO Memory: 10 samples, avg is 91.3MB, max is 138.3MB 
INFO Execution took 858.2966ms
moshe010 added a commit to moshe010/ib-kubernetes that referenced this issue Mar 16, 2020
1.24.0 causing out-of-memory see [1]
so for now pin the version to 1.23.8

[1] - golangci/golangci-lint#994
moshe010 added a commit to moshe010/ib-kubernetes that referenced this issue Mar 16, 2020
in golangci-lint 1.24.0 causing out-of-memory see [1]
so for now pin the version to 1.23.8

[1] - golangci/golangci-lint#994
adrianchiris added a commit to adrianchiris/rdma-cni-1 that referenced this issue Mar 17, 2020
Limit golangci-lint version to 1.23.8 due to memroy issue[1].

In addition its generaly recommended to fix the linter version
to avoid unexpectedly failing on the project in case of new
checks that are added.

[1] golangci/golangci-lint#994
ray-milkey referenced this issue in onosproject/onos-config Mar 17, 2020
…1106)

* Roll back linter version to get around memory consumption problems

* Wrong go.mod
raulk added a commit to testground/testground that referenced this issue Mar 18, 2020
raulk added a commit to testground/testground that referenced this issue Mar 18, 2020
* fix makefile: explicitly set bash as shell; tune lint.

* unquote SHELL.

* downgrade golangci-lint to v1.23.6.

v1.24.0 has memory usage regressions: golangci/golangci-lint#994
@aeneasr
Copy link

aeneasr commented Mar 21, 2020

We are also experiencing this issue.

@ldez
Copy link
Member

ldez commented Mar 22, 2020

I think that is related to #987

@invidian
Copy link
Contributor Author

I think that is related to #987

Why you think so?

facebook-github-bot pushed a commit to magma/magma that referenced this issue Mar 23, 2020
Summary:
v1.24 version of golangci-lint gets oomed killed during execution on circleci.
see golangci/golangci-lint#994 for more info.

Reviewed By: naor9991

Differential Revision: D20592270

fbshipit-source-id: 5a8b5f90555f18abfd0319615e9aaec1e7473ff4
@ldez
Copy link
Member

ldez commented Mar 23, 2020

@ldez
Copy link
Member

ldez commented Mar 25, 2020

friendly ping @jirfag

@alethenorio
Copy link

Hitting this issue constantly after upgrading to 1.14 and 1.24.0

@StevenACoffman
Copy link
Contributor

The latest release of staticcheck is still 2020.1.3 as of this writing.

From comment:

Unused is the only linter that eats a ton of memory because it can't work incrementally. You can disable it. You can make an issue in staticcheck GitHub repository about it: I think its optimization is possible.

Past closed issues:

My understanding is that there is no open issue for the memory usage of unused in staticcheck.

I wonder if it might be a good idea to warn people who have unused enabled in golangci-lint until it is better optimized in staticcheck.

@ernado ernado added topic: memory Huge memory consumption help wanted Issue that needs help from a contributor labels Apr 20, 2020
@ernado
Copy link
Member

ernado commented Apr 20, 2020

Hey, I'm very sorry for lack of response :(

You are right, this should be related to unused linter and staticcheck.
I will try to investigate how to fix that. I've hoped that switching from patched staticcheck to upstream will not brake things, but meh.

Current workaround is to disable unused linter.

Any PR that will help to mitigate this issue will be welcomed and reviewed ASAP.

Also, please ping me instead of jirfag.

@johanbrandhorst
Copy link

I believe @dominikh has been recently working on improving the footprint of his tools.

@dominikh
Copy link

I believe @dominikh has been recently working on improving the footprint of his tools.

That is true. However, the vast majority of the footprint lies in how the analyses are run, i.e. the staticcheck command or, in this case, golangci-lint. Though I am working on related changes in unused to aid the runner, which would also benefit golangci-lint.

@StevenACoffman
Copy link
Contributor

Would emitting a warning message whenever the linter is started while unused is enabled cut down on end user confusion (and bug reports) until a better long term solution is in place?

@ernado
Copy link
Member

ernado commented Apr 20, 2020

Generating warnings for each unused linter run can be annoying, but seems like it is the only option until OOM is fixed.

Feel free to send PR ⚡

@ernado
Copy link
Member

ernado commented Apr 21, 2020

Also it is related to #898

ernado added a commit that referenced this issue Apr 22, 2020
Hotfix for `failed prerequisites` errors.
Actual cause is still unknown.

Revert: #987
Ref: #994, #995, #1011
@ernado ernado added the cursed This issue is doomed. label Apr 22, 2020
@ernado
Copy link
Member

ernado commented Apr 22, 2020

I had to downgrade staticcheck to stabilize project.
Please try v1.25.0 version.

Also please don't blame staticcheck for those issues, they can be caused by the way we are using it.
Will update back only after fixing those issues (on any side).

@ernado
Copy link
Member

ernado commented Apr 25, 2020

Closing for now.

Please open new issue for any regression.

@ernado ernado closed this as completed Apr 25, 2020
jirfag added a commit that referenced this issue May 3, 2020
The primary improvement is in early clearing of
analyzed package's TypeInfo, facts, etc for
whole program analyzers (`unused`). Clear it when it
becomes unused and GC collects them early. Initially this
clearing was performed for all analyzers except `unused`.

Update staticcheck from v0.0.1-2019.2.3 to v0.0.1-2020.1.4

Also in this commit:
  * speed up loading packages from export data (2.5s -> 2.1s for std)
    by not using mutex for export data since it was allowed in
    x/tools#07722704da13
  * make an order of execution of linters stable
  * update renameio and robustio
  * use robustio in caching

Relates: #987, #994, #995, #1011
@jirfag
Copy link
Member

jirfag commented May 3, 2020

Hi,
I've reduced memory usage when running unused in #1063. The problem was in how our loader and runner clears unused fields.

Memory usage on flexkube dropped from 10 GB to 1 GB.

jirfag added a commit that referenced this issue May 3, 2020
The primary improvement is in early clearing of
analyzed package's TypeInfo, facts, etc for
whole program analyzers (`unused`). Clear it when it
becomes unused and GC collects them early. Initially this
clearing was performed for all analyzers except `unused`.

Update staticcheck from v0.0.1-2019.2.3 to v0.0.1-2020.1.4

Also in this commit:
  * speed up loading packages from export data (2.5s -> 2.1s for std)
    by not using mutex for export data since it was allowed in
    x/tools#07722704da13
  * make an order of execution of linters stable
  * update renameio and robustio
  * use robustio in caching

Relates: #987, #994, #995, #1011
jirfag added a commit that referenced this issue May 3, 2020
The primary improvement is in early clearing of
analyzed package's TypeInfo, facts, etc for
whole program analyzers (`unused`). Clear it when it
becomes unused and GC collects them early. Initially this
clearing was performed for all analyzers except `unused`.

Update staticcheck from v0.0.1-2019.2.3 to v0.0.1-2020.1.4

Also in this commit:
  * speed up loading packages from export data (2.5s -> 2.1s for std)
    by not using mutex for export data since it was allowed in
    x/tools#07722704da13
  * make an order of execution of linters stable
  * update renameio and robustio
  * use robustio in caching

Relates: #987, #994, #995, #1011
jirfag added a commit that referenced this issue May 5, 2020
The primary improvement is in early clearing of
analyzed package's TypeInfo, facts, etc for
whole program analyzers (`unused`). Clear it when it
becomes unused and GC collects them early. Initially this
clearing was performed for all analyzers except `unused`.

Update staticcheck from v0.0.1-2019.2.3 to v0.0.1-2020.1.4

Also in this commit:
  * speed up loading packages from export data (2.5s -> 2.1s for std)
    by not using mutex for export data since it was allowed in
    x/tools#07722704da13
  * make an order of execution of linters stable
  * update renameio and robustio
  * use robustio in caching

Relates: #987, #994, #995, #1011
119Vik pushed a commit to 119Vik/magma that referenced this issue Jul 21, 2020
Summary:
v1.24 version of golangci-lint gets oomed killed during execution on circleci.
see golangci/golangci-lint#994 for more info.

Reviewed By: naor9991

Differential Revision: D20592270

fbshipit-source-id: 5a8b5f90555f18abfd0319615e9aaec1e7473ff4
@ldez ldez removed the help wanted Issue that needs help from a contributor label Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cursed This issue is doomed. topic: memory Huge memory consumption
Projects
None yet
Development

No branches or pull requests

9 participants