-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Using more cores makes golangci-lint run slower (?) #5149
Comments
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors. |
Hello, In some cases using all the cores doesn't provide the best performance, this is not unexpected because the CPU is one of the limits of a system when using parallel processes. I think it's because we are hitting other limitations than the CPU related to concurrency access (memory, FS, other processes, etc.). But as you can see the "best" value for the CPU depends on the system, so it's not possible to do something smart on this topic.
I also have 16 cores, but on Linux amd64. Also, the cache is not a global thing for golangci-lint, I mean it's not "all or nothing" because the cache is by package, and the invalidation of cache is by package too. default, no cache$ golangci-lint cache clean; golangci-lint run -v
INFO golangci-lint has version 1.62.0 built with go1.23.2 from 22b58c9b on 2024-11-10T19:09:02Z
INFO [config_reader] Config search paths: [./ /home/ldez/sources/golangci/golangci-lint /home/ldez/sources/golangci /home/ldez/sources /home/ldez /home /]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 36 linters: [bodyclose copyloopvar depguard dogsled dupl errcheck errorlint funlen gocheckcompilerdirectives gochecknoinits goconst gocritic gocyclo godox gofmt goimports goprintffuncname gosec gosimple govet ineffassign intrange lll misspell mnd nakedret noctx nolintlint revive staticcheck stylecheck testifylint unconvert unparam unused whitespace]
INFO [loader] Go packages loading at mode 8767 (files|types_sizes|compiled_files|deps|exports_file|imports|name) took 1.732099451s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 37.73902ms
INFO [linters_context/goanalysis] analyzers took 5m57.225474923s with top 10 stages: gocritic: 3m46.436341339s, buildir: 57.424044053s, goimports: 5.330305363s, dupl: 3.311811385s, the_only_name: 2.446353019s, unconvert: 2.172881869s, inspect: 2.003145912s, ctrlflow: 1.993345694s, printf: 1.992951633s, fact_deprecated: 1.64308803s
INFO [runner/skip_dirs] Skipped 3 issues from dir internal/go/quoted by pattern internal/go
INFO [runner/skip_dirs] Skipped 2 issues from dir internal/go/robustio by pattern internal/go
INFO [runner/skip_dirs] Skipped 3 issues from dir internal/go/testenv by pattern internal/go
INFO [runner/skip_dirs] Skipped 2 issues from dir internal/go/mmap by pattern internal/go
INFO [runner/skip_dirs] Skipped 3 issues from dir test/testdata_etc/abspath by pattern test/testdata_etc
INFO [runner/skip_dirs] Skipped 1 issues from dir test/testdata_etc/unused_exported/lib by pattern test/testdata_etc
INFO [runner/skip_dirs] Skipped 112 issues from dir internal/go/cache by pattern internal/go
INFO [runner] Issues before processing: 510, after processing: 0
INFO [runner] Processors filtering stat (in/out): skip_dirs: 510/384, exclude: 384/384, path_prettifier: 510/510, cgo: 510/510, filename_unadjuster: 510/510, identifier_marker: 384/384, invalid_issue: 510/510, skip_files: 510/510, autogenerated_exclude: 384/384, exclude-rules: 384/68, nolint: 68/0
INFO [runner] processing took 66.981558ms with stages: autogenerated_exclude: 19.282449ms, exclude-rules: 18.039587ms, path_prettifier: 12.818189ms, nolint: 7.795339ms, identifier_marker: 7.305769ms, skip_dirs: 1.660043ms, cgo: 35.439µs, invalid_issue: 24.406µs, filename_unadjuster: 10.035µs, max_same_issues: 4.352µs, uniq_by_line: 1.267µs, max_from_linter: 1.092µs, skip_files: 843ns, fixer: 677ns, exclude: 639ns, sort_results: 338ns, diff: 279ns, max_per_file_from_linter: 227ns, source_code: 174ns, severity-rules: 173ns, path_shortener: 129ns, path_prefixer: 112ns
INFO [runner] linters took 21.30504619s with stages: goanalysis_metalinter: 21.237903708s
INFO File cache stats: 425 entries of total size 915.0KiB
INFO Memory: 229 samples, avg is 2257.2MB, max is 4096.9MB
INFO Execution took 23.078625285s -j 4, no cache$ golangci-lint cache clean; golangci-lint run -v -j 4
INFO golangci-lint has version 1.62.0 built with go1.23.2 from 22b58c9b on 2024-11-10T19:09:02Z
INFO [config_reader] Config search paths: [./ /home/ldez/sources/golangci/golangci-lint /home/ldez/sources/golangci /home/ldez/sources /home/ldez /home /]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 36 linters: [bodyclose copyloopvar depguard dogsled dupl errcheck errorlint funlen gocheckcompilerdirectives gochecknoinits goconst gocritic gocyclo godox gofmt goimports goprintffuncname gosec gosimple govet ineffassign intrange lll misspell mnd nakedret noctx nolintlint revive staticcheck stylecheck testifylint unconvert unparam unused whitespace]
INFO [loader] Go packages loading at mode 8767 (types_sizes|compiled_files|exports_file|files|imports|deps|name) took 1.727325982s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 15.788824ms
INFO [linters_context/goanalysis] analyzers took 3m0.18741501s with top 10 stages: gocritic: 1m53.226397463s, buildir: 31.889571815s, goimports: 5.636113439s, dupl: 5.541761763s, the_only_name: 4.84472518s, unconvert: 4.202925337s, fact_deprecated: 1.058907669s, inspect: 1.040574396s, printf: 769.004304ms, ctrlflow: 672.834358ms
INFO [runner/skip_dirs] Skipped 1 issues from dir test/testdata_etc/unused_exported/lib by pattern test/testdata_etc
INFO [runner/skip_dirs] Skipped 112 issues from dir internal/go/cache by pattern internal/go
INFO [runner/skip_dirs] Skipped 3 issues from dir internal/go/quoted by pattern internal/go
INFO [runner/skip_dirs] Skipped 2 issues from dir internal/go/robustio by pattern internal/go
INFO [runner/skip_dirs] Skipped 3 issues from dir internal/go/testenv by pattern internal/go
INFO [runner/skip_dirs] Skipped 2 issues from dir internal/go/mmap by pattern internal/go
INFO [runner/skip_dirs] Skipped 3 issues from dir test/testdata_etc/abspath by pattern test/testdata_etc
INFO [runner] Issues before processing: 510, after processing: 0
INFO [runner] Processors filtering stat (in/out): cgo: 510/510, exclude: 384/384, filename_unadjuster: 510/510, invalid_issue: 510/510, identifier_marker: 384/384, exclude-rules: 384/68, autogenerated_exclude: 384/384, path_prettifier: 510/510, skip_files: 510/510, skip_dirs: 510/384, nolint: 68/0
INFO [runner] processing took 22.537614ms with stages: exclude-rules: 9.761359ms, nolint: 4.937221ms, identifier_marker: 3.499617ms, path_prettifier: 2.08714ms, autogenerated_exclude: 1.407552ms, skip_dirs: 779.621µs, cgo: 31.048µs, invalid_issue: 21.607µs, filename_unadjuster: 9.155µs, max_same_issues: 982ns, skip_files: 301ns, uniq_by_line: 295ns, fixer: 273ns, diff: 272ns, max_from_linter: 203ns, exclude: 201ns, sort_results: 185ns, source_code: 168ns, severity-rules: 152ns, max_per_file_from_linter: 95ns, path_prefixer: 84ns, path_shortener: 83ns
INFO [runner] linters took 38.037171283s with stages: goanalysis_metalinter: 38.014575542s
INFO File cache stats: 425 entries of total size 915.0KiB
INFO Memory: 366 samples, avg is 1539.6MB, max is 2797.9MB
INFO Execution took 39.784760618s -j 4, cache$ golangci-lint cache clean; golangci-lint run -j 4; golangci-lint run -v -j 4
INFO golangci-lint has version 1.62.0 built with go1.23.2 from 22b58c9b on 2024-11-10T19:09:02Z
INFO [config_reader] Config search paths: [./ /home/ldez/sources/golangci/golangci-lint /home/ldez/sources/golangci /home/ldez/sources /home/ldez /home /]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 36 linters: [bodyclose copyloopvar depguard dogsled dupl errcheck errorlint funlen gocheckcompilerdirectives gochecknoinits goconst gocritic gocyclo godox gofmt goimports goprintffuncname gosec gosimple govet ineffassign intrange lll misspell mnd nakedret noctx nolintlint revive staticcheck stylecheck testifylint unconvert unparam unused whitespace]
INFO [loader] Go packages loading at mode 8767 (compiled_files|exports_file|name|types_sizes|deps|files|imports) took 744.660194ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 11.895893ms
INFO [linters_context/goanalysis] analyzers took 0s with no stages
INFO [runner/skip_dirs] Skipped 2 issues from dir internal/go/robustio by pattern internal/go
INFO [runner/skip_dirs] Skipped 2 issues from dir internal/go/mmap by pattern internal/go
INFO [runner/skip_dirs] Skipped 1 issues from dir test/testdata_etc/unused_exported/lib by pattern test/testdata_etc
INFO [runner/skip_dirs] Skipped 3 issues from dir internal/go/testenv by pattern internal/go
INFO [runner/skip_dirs] Skipped 3 issues from dir test/testdata_etc/abspath by pattern test/testdata_etc
INFO [runner/skip_dirs] Skipped 112 issues from dir internal/go/cache by pattern internal/go
INFO [runner/skip_dirs] Skipped 3 issues from dir internal/go/quoted by pattern internal/go
INFO [runner] Issues before processing: 510, after processing: 0
INFO [runner] Processors filtering stat (in/out): skip_dirs: 510/384, nolint: 68/0, filename_unadjuster: 510/510, invalid_issue: 510/510, path_prettifier: 510/510, autogenerated_exclude: 384/384, exclude: 384/384, cgo: 510/510, identifier_marker: 384/384, skip_files: 510/510, exclude-rules: 384/68
INFO [runner] processing took 24.748996ms with stages: exclude-rules: 11.656569ms, nolint: 4.604246ms, identifier_marker: 3.737341ms, path_prettifier: 2.467792ms, autogenerated_exclude: 1.339074ms, skip_dirs: 850.406µs, invalid_issue: 52.617µs, cgo: 28.406µs, filename_unadjuster: 9.422µs, max_same_issues: 837ns, fixer: 314ns, uniq_by_line: 297ns, skip_files: 288ns, max_from_linter: 232ns, exclude: 220ns, sort_results: 208ns, diff: 192ns, source_code: 147ns, max_per_file_from_linter: 111ns, severity-rules: 106ns, path_shortener: 88ns, path_prefixer: 83ns
INFO [runner] linters took 287.588367ms with stages: goanalysis_metalinter: 262.776579ms
INFO File cache stats: 0 entries of total size 0B
INFO Memory: 12 samples, avg is 46.6MB, max is 109.0MB
INFO Execution took 1.047746156s default, no cache$ golangci-lint cache clean; golangci-lint run; golangci-lint run -v
INFO golangci-lint has version 1.62.0 built with go1.23.2 from 22b58c9b on 2024-11-10T19:09:02Z
INFO [config_reader] Config search paths: [./ /home/ldez/sources/golangci/golangci-lint /home/ldez/sources/golangci /home/ldez/sources /home/ldez /home /]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 36 linters: [bodyclose copyloopvar depguard dogsled dupl errcheck errorlint funlen gocheckcompilerdirectives gochecknoinits goconst gocritic gocyclo godox gofmt goimports goprintffuncname gosec gosimple govet ineffassign intrange lll misspell mnd nakedret noctx nolintlint revive staticcheck stylecheck testifylint unconvert unparam unused whitespace]
INFO [loader] Go packages loading at mode 8767 (types_sizes|compiled_files|deps|exports_file|files|imports|name) took 740.435398ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 8.066134ms
INFO [linters_context/goanalysis] analyzers took 0s with no stages
INFO [runner/skip_dirs] Skipped 1 issues from dir test/testdata_etc/unused_exported/lib by pattern test/testdata_etc
INFO [runner/skip_dirs] Skipped 2 issues from dir internal/go/robustio by pattern internal/go
INFO [runner/skip_dirs] Skipped 3 issues from dir internal/go/testenv by pattern internal/go
INFO [runner/skip_dirs] Skipped 3 issues from dir test/testdata_etc/abspath by pattern test/testdata_etc
INFO [runner/skip_dirs] Skipped 2 issues from dir internal/go/mmap by pattern internal/go
INFO [runner/skip_dirs] Skipped 3 issues from dir internal/go/quoted by pattern internal/go
INFO [runner/skip_dirs] Skipped 112 issues from dir internal/go/cache by pattern internal/go
INFO [runner] Issues before processing: 510, after processing: 0
INFO [runner] Processors filtering stat (in/out): filename_unadjuster: 510/510, skip_files: 510/510, skip_dirs: 510/384, identifier_marker: 384/384, exclude: 384/384, invalid_issue: 510/510, nolint: 68/0, path_prettifier: 510/510, autogenerated_exclude: 384/384, exclude-rules: 384/68, cgo: 510/510
INFO [runner] processing took 28.226385ms with stages: exclude-rules: 13.112296ms, nolint: 5.037033ms, identifier_marker: 4.501248ms, path_prettifier: 2.731537ms, autogenerated_exclude: 1.691337ms, skip_dirs: 1.049224ms, cgo: 52.742µs, invalid_issue: 32.334µs, filename_unadjuster: 15.449µs, max_same_issues: 867ns, uniq_by_line: 320ns, fixer: 294ns, skip_files: 227ns, exclude: 225ns, diff: 216ns, sort_results: 210ns, source_code: 188ns, max_from_linter: 165ns, severity-rules: 163ns, max_per_file_from_linter: 114ns, path_shortener: 105ns, path_prefixer: 91ns
INFO [runner] linters took 273.293577ms with stages: goanalysis_metalinter: 245.000884ms
INFO File cache stats: 0 entries of total size 0B
INFO Memory: 12 samples, avg is 46.5MB, max is 105.5MB
INFO Execution took 1.026388844s -j 6, no cache$ golangci-lint cache clean; golangci-lint run -v -j 6
INFO golangci-lint has version 1.62.0 built with go1.23.2 from 22b58c9b on 2024-11-10T19:09:02Z
INFO [config_reader] Config search paths: [./ /home/ldez/sources/golangci/golangci-lint /home/ldez/sources/golangci /home/ldez/sources /home/ldez /home /]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 36 linters: [bodyclose copyloopvar depguard dogsled dupl errcheck errorlint funlen gocheckcompilerdirectives gochecknoinits goconst gocritic gocyclo godox gofmt goimports goprintffuncname gosec gosimple govet ineffassign intrange lll misspell mnd nakedret noctx nolintlint revive staticcheck stylecheck testifylint unconvert unparam unused whitespace]
INFO [loader] Go packages loading at mode 8767 (files|imports|name|types_sizes|exports_file|deps|compiled_files) took 772.596978ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 10.451495ms
INFO [linters_context/goanalysis] analyzers took 3m17.412213722s with top 10 stages: gocritic: 2m1.823760693s, buildir: 33.6956026s, goimports: 5.404502777s, dupl: 5.185422288s, unconvert: 4.23512608s, the_only_name: 4.063124552s, inspect: 1.244415709s, fact_deprecated: 1.150706743s, printf: 1.062151489s, ctrlflow: 987.108511ms
INFO [runner/skip_dirs] Skipped 2 issues from dir internal/go/mmap by pattern internal/go
INFO [runner/skip_dirs] Skipped 3 issues from dir internal/go/testenv by pattern internal/go
INFO [runner/skip_dirs] Skipped 3 issues from dir test/testdata_etc/abspath by pattern test/testdata_etc
INFO [runner/skip_dirs] Skipped 1 issues from dir test/testdata_etc/unused_exported/lib by pattern test/testdata_etc
INFO [runner/skip_dirs] Skipped 112 issues from dir internal/go/cache by pattern internal/go
INFO [runner/skip_dirs] Skipped 3 issues from dir internal/go/quoted by pattern internal/go
INFO [runner/skip_dirs] Skipped 2 issues from dir internal/go/robustio by pattern internal/go
INFO [runner] Issues before processing: 510, after processing: 0
INFO [runner] Processors filtering stat (in/out): skip_dirs: 510/384, autogenerated_exclude: 384/384, exclude-rules: 384/68, cgo: 510/510, path_prettifier: 510/510, skip_files: 510/510, exclude: 384/384, nolint: 68/0, filename_unadjuster: 510/510, invalid_issue: 510/510, identifier_marker: 384/384
INFO [runner] processing took 22.894171ms with stages: exclude-rules: 10.161354ms, nolint: 4.712857ms, identifier_marker: 3.669547ms, path_prettifier: 2.049031ms, autogenerated_exclude: 1.429455ms, skip_dirs: 813.58µs, cgo: 23.641µs, invalid_issue: 21.659µs, filename_unadjuster: 9.612µs, max_same_issues: 924ns, skip_files: 370ns, fixer: 308ns, uniq_by_line: 286ns, exclude: 236ns, max_from_linter: 228ns, diff: 215ns, max_per_file_from_linter: 204ns, sort_results: 201ns, severity-rules: 159ns, path_shortener: 110ns, source_code: 107ns, path_prefixer: 87ns
INFO [runner] linters took 28.108728303s with stages: goanalysis_metalinter: 28.085775658s
INFO File cache stats: 425 entries of total size 915.0KiB
INFO Memory: 278 samples, avg is 1747.0MB, max is 2968.0MB
INFO Execution took 28.895793532s -j 6, cache$ golangci-lint cache clean; golangci-lint run -j 6; golangci-lint run -v -j 6
INFO golangci-lint has version 1.62.0 built with go1.23.2 from 22b58c9b on 2024-11-10T19:09:02Z
INFO [config_reader] Config search paths: [./ /home/ldez/sources/golangci/golangci-lint /home/ldez/sources/golangci /home/ldez/sources /home/ldez /home /]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 36 linters: [bodyclose copyloopvar depguard dogsled dupl errcheck errorlint funlen gocheckcompilerdirectives gochecknoinits goconst gocritic gocyclo godox gofmt goimports goprintffuncname gosec gosimple govet ineffassign intrange lll misspell mnd nakedret noctx nolintlint revive staticcheck stylecheck testifylint unconvert unparam unused whitespace]
INFO [loader] Go packages loading at mode 8767 (compiled_files|exports_file|files|deps|imports|name|types_sizes) took 666.656723ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 29.799855ms
INFO [linters_context/goanalysis] analyzers took 0s with no stages
INFO [runner/skip_dirs] Skipped 112 issues from dir internal/go/cache by pattern internal/go
INFO [runner/skip_dirs] Skipped 1 issues from dir test/testdata_etc/unused_exported/lib by pattern test/testdata_etc
INFO [runner/skip_dirs] Skipped 3 issues from dir internal/go/testenv by pattern internal/go
INFO [runner/skip_dirs] Skipped 2 issues from dir internal/go/robustio by pattern internal/go
INFO [runner/skip_dirs] Skipped 3 issues from dir test/testdata_etc/abspath by pattern test/testdata_etc
INFO [runner/skip_dirs] Skipped 2 issues from dir internal/go/mmap by pattern internal/go
INFO [runner/skip_dirs] Skipped 3 issues from dir internal/go/quoted by pattern internal/go
INFO [runner] Issues before processing: 510, after processing: 0
INFO [runner] Processors filtering stat (in/out): exclude: 384/384, exclude-rules: 384/68, invalid_issue: 510/510, autogenerated_exclude: 384/384, skip_dirs: 510/384, path_prettifier: 510/510, skip_files: 510/510, identifier_marker: 384/384, nolint: 68/0, cgo: 510/510, filename_unadjuster: 510/510
INFO [runner] processing took 22.933408ms with stages: exclude-rules: 9.730914ms, nolint: 4.479087ms, identifier_marker: 3.732948ms, path_prettifier: 2.563195ms, autogenerated_exclude: 1.361272ms, skip_dirs: 835.636µs, invalid_issue: 88.818µs, cgo: 81.117µs, filename_unadjuster: 57.503µs, max_same_issues: 887ns, uniq_by_line: 290ns, fixer: 271ns, skip_files: 222ns, diff: 220ns, exclude: 212ns, sort_results: 184ns, severity-rules: 154ns, max_from_linter: 121ns, source_code: 99ns, max_per_file_from_linter: 95ns, path_prefixer: 82ns, path_shortener: 81ns
INFO [runner] linters took 267.356317ms with stages: goanalysis_metalinter: 244.325956ms
INFO File cache stats: 0 entries of total size 0B
INFO Memory: 11 samples, avg is 46.0MB, max is 104.0MB
INFO Execution took 967.3105ms |
Welcome
typecheck
section of the FAQ.Description of the problem
I noticed that both when running a "clean" and a "cached"
golangci-lint
, setting the core limit lower (with the-j
option) seems to improve performance, to a point. It is especially noticeable for cached linting runs.I first noticed this in our own internal repository but I have reproduced it using the golangci-lint repo.
All these commands were run on a Macbook Pro M4 Max (where golangci-lint defaults to using 16 cores).
golangci-lint run -v (after golangci-lint cache clean)
golangci-lint run -v -j 4 (after golangci-lint cache clean)
golangci-lint run -v (with cache)
Ran this five times, execution time ranged between 2,14s and 2,37s.
golangci-lint run -v -j 4 (with cache)
Also ran this five times, execution time ranged from 1,43s to 1,69s
Version of golangci-lint
Configuration
# paste configuration file or CLI flags here
Go environment
The text was updated successfully, but these errors were encountered: