Skip to content

Ignores GOMAXPROCS environment variable #4476

@e-compton-bb

Description

@e-compton-bb

Welcome

Description of the problem

We use GOMAXPROCS=2 to cap the number of cpus in our CI to 2 for our builds. But golangic-lint unexpectedly seems to ignore it.

In this sample it uses 647% when it should be less that 200%

GOMAXPROCS=2 golangci-lint run -v ./...  47.04s user 4.70s system 647% cpu 7.995 total

Works fine when you explicitly pass the -j 2 option

GOMAXPROCS=2 golangci-lint run -v -j 2 ./...  31.60s user 3.46s system 172% cpu 20.336 total

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.56.2 built with go1.22.0 from 58a724a on 2024-02-15T12:52:06Z

Configuration

GOMAXPROCS=2 golangci-lint run -v ./...

Go environment

$ go version && go env
go version go1.22.0 darwin/arm64
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/e.compton/Library/Caches/go-build'
GOENV='/Users/e.compton/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/e.compton/go/pkg/mod'
GONOPROXY='github.com/blackbird-plc'
GONOSUMDB='github.com/blackbird-plc'
GOOS='darwin'
GOPATH='/Users/e.compton/go'
GOPRIVATE='github.com/blackbird-plc'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/opt/go/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/opt/go/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.0'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/e.compton/Projects/notification-service/email_sender/service/go.mod'
GOWORK='/Users/e.compton/Projects/notification-service/go.work'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/5v/bm0wv82938q7x9lqr7z_xgq40000gq/T/go-build2747345793=/tmp/go-build -gno-record-gcc-switches -fno-common'

Verbose output of running

$ golangci-lint cache clean
$ GOMAXPROCS=2 golangci-lint run -v
INFO [config_reader] Config search paths: [./ /Users/e.compton/Projects/notification-service/email_sender/service /Users/e.compton/Projects/notification-service/email_sender /Users/e.compton/Projects/notification-service /Users/e.compton/Projects /Users/e.compton /Users /] 
INFO [lintersdb] Active 6 linters: [errcheck gosimple govet ineffassign staticcheck unused] 
INFO [loader] Go packages loading at mode 575 (types_sizes|compiled_files|exports_file|files|imports|name|deps) took 932.027875ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 545.834µs 
INFO [linters_context/goanalysis] analyzers took 1m2.62255131s with top 10 stages: buildir: 31.371990338s, printf: 5.084784739s, ctrlflow: 4.770101734s, fact_deprecated: 4.607753423s, fact_purity: 4.110334194s, SA5012: 3.931280238s, nilness: 3.830423092s, typedness: 3.711264409s, inspect: 1.171193207s, SA1002: 3.115333ms 
INFO [runner] processing took 1.708µs with stages: max_same_issues: 334ns, skip_dirs: 167ns, sort_results: 166ns, nolint: 125ns, severity-rules: 125ns, path_prettifier: 125ns, path_prefixer: 125ns, filename_unadjuster: 125ns, cgo: 125ns, source_code: 42ns, max_from_linter: 42ns, uniq_by_line: 42ns, exclude: 42ns, exclude-rules: 41ns, diff: 41ns, identifier_marker: 41ns, max_per_file_from_linter: 0s, skip_files: 0s, autogenerated_exclude: 0s, path_shortener: 0s, fixer: 0s 
INFO [runner] linters took 6.849623917s with stages: goanalysis_metalinter: 6.849594584s 
INFO File cache stats: 0 entries of total size 0B 
INFO Memory: 79 samples, avg is 1168.9MB, max is 2642.0MB 
INFO Execution took 7.790884958s 

A minimal reproducible example or link to a public repository

// add your code here

Validation

  • Yes, I've included all information above (version, config, etc.).

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions