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

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

Open
2 of 3 tasks
orestisfl opened this issue Sep 19, 2024 · 4 comments
Open
2 of 3 tasks

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

orestisfl opened this issue Sep 19, 2024 · 4 comments
Labels
breaking enhancement New feature or improvement

Comments

@orestisfl
Copy link

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

@orestisfl orestisfl added the enhancement New feature or improvement label Sep 19, 2024
@orestisfl orestisfl changed the title Limit concurrency according to Linux container CPU quota Limit concurrency according to Linux container CPU quota by default Sep 19, 2024
@ldez ldez added the breaking label Sep 19, 2024
@ldez
Copy link
Member

ldez commented Sep 19, 2024

Hello,

for now, we don't plan to change the default as it's a breaking change.

@orestisfl
Copy link
Author

Thanks @ldez. FMI, what's the usecase that would break? From my perspective, respecting CFS limits is a desired behavior.

@Zxilly

This comment was marked as off-topic.

@ldez

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking enhancement New feature or improvement
Projects
None yet
Development

No branches or pull requests

3 participants