Skip to content

Limit concurrency according to Linux container CPU quota by default #5031

Closed
@orestisfl

Description

@orestisfl

Welcome

Your feature request related to a problem? Please describe

golangci-lint supports automatically limiting the CPU quota if you use the --concurrency=0 flag / run.concurrency: 0 option.

However, the concurrency is set to runtime.NumCPU() and not 0 by default:

return runtime.NumCPU()
.

As a result, golangci-lint will run by default with the number of detected logical cores instead of the limit. We observed that running golangci-lint on k8s resulted in it using 32 CPUs even though only 4 were available according to the limit set to the pod. That resulted in increased memory usage probably because the different threads were starved for CPU and were allocating memory in parallel. Eventually, the pod was OOM-killed after reaching the 8GB limit. By manually setting -j 4 or -j 0 we confirmed that the memory usage dropped by 50% and execution time was faster as well.

Describe the solution you'd like

Switch the default behavior to be equivalent to today's -j 0 behavior.

Describe alternatives you've considered

Manually setting the desired concurrency.

Additional context

No response

Supporter

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions