feat: automatically set GOMEMLIMIT - #16260
Conversation
Signed commits reportAll 1 commit between |
6e6b89a to
6d6c9ac
Compare
|
🤖 Automated comment |
Closes grafana#10860 Signed-off-by: Timon Engelke <timon.engelke@inovex.de>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 78c8e85. Configure here.
| "slices" | ||
| "strings" | ||
|
|
||
| _ "github.com/KimMachineGun/automemlimit" |
There was a problem hiding this comment.
Ballast conflicts with auto GOMEMLIMIT
Medium Severity
Enabling automemlimit sets GOMEMLIMIT from the cgroup memory limit while Mimir still allocates large ballasts (ruler default 1GiB, distributor 1GiB, querier 256Mi). Ballast counts as live memory under GOMEMLIMIT, so when ballast is near or above the auto-set limit the GC thrashes permanently. Helm already warns about this for manually set GOMEMLIMIT; automatic enabling makes it much easier to hit, especially for ruler deployments that set a modest memory limit.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 78c8e85. Configure here.
There was a problem hiding this comment.
I think the ballast pattern is no longer good practice, setting GOMEMLIMIT and GOGC should be able to replace it. But that would of course be a bigger change.


What this PR does
This PR adds
automemlimitto automatically setGOMEMLIMITbased on the available memory for the application. It makes Mimir more resilient by preventing OOM kills because garbage collection is run based on this setting.automemlimitis a standard of settingGOMEMLIMITused, e.g., bykube-state-metrics,prometheus,prometheus-operator,alertmanager, andistio.If you prefer, I can also make it optional or add additional flags.
This PR is an alternative to calculating the environment variable in the Helm Chart which requires a lot of templating logic (e.g. #12341).
Which issue(s) this PR fixes or relates to
Fixes #10860
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]. If changelog entry is not needed, please add thechangelog-not-neededlabel to the PR.about-versioning.mdupdated with experimental features.