Skip to content

Commit 0e9fea9

Browse files
committed
reduce golangci-lint overhead for jenkins worker
The crossplane jenkins worker node only has 10gb of RAM. With 1.17.1 of golangci-lint we regularly see 10gb consumed while linting in local environments. The changes suggested here appear to improve the overhead. golangci/golangci-lint#337 (comment) Prior to the bump to 1.17.1, golangci-lint was taking 6-8GB of RAM and completing in 10s. With the reduction in overhead to golangci-lint that this PR introduces, linting consumes between 8-9GB of ram and completes in 30s using the same environment. The intent here is to continue using latest golangci-lint with the current Jenkins configuration, sacrificing some time. Additional measure can be made, such as using `--fast` tests only or further increasing the LINT_GOGC value. https://github.com/golangci/golangci-lint#configuration https://github.com/golangci/golangci-lint#memory-usage-of-golangci-lint Signed-off-by: Marques Johansson <[email protected]>
1 parent 1a0fb71 commit 0e9fea9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

makelib/golang.mk

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,10 @@ GO_OUT_EXT := .exe
117117
endif
118118

119119
ifeq ($(RUNNING_IN_CI),true)
120+
# Reduce concurrency to reduce RAM requirements on jenkins worker nodes
121+
# increase deadline to 3m (from default 1m, crossplane default 2m) to potentially compensate for less concurrency
120122
# Output checkstyle XML rather than human readable output.
121-
GO_LINT_ARGS := --out-format=checkstyle > $(GO_LINT_OUTPUT)/checkstyle.xml
123+
GO_LINT_ARGS := --concurrency=1 --deadline=3m0s --out-format=checkstyle > $(GO_LINT_OUTPUT)/checkstyle.xml
122124

123125
# Output verbose tests that can be parsed into JUnit XML.
124126
GO_TEST_FLAGS += -v
@@ -192,7 +194,7 @@ go.test.integration: $(GOJUNIT)
192194
go.lint: $(GOLANGCILINT)
193195
@$(INFO) golangci-lint
194196
@mkdir -p $(GO_LINT_OUTPUT)
195-
@$(GOLANGCILINT) run $(GO_LINT_ARGS) || $(FAIL)
197+
@LINT_GOGC=20 $(GOLANGCILINT) run $(GO_LINT_ARGS) || $(FAIL)
196198
@$(OK) golangci-lint
197199

198200
go.vet:

0 commit comments

Comments
 (0)