Repository navigation
Conversation
The resource monitor divides heap objects by GOMEMLIMIT, so a heap rejection threshold is a fraction of the GC's own target. When GOMEMLIMIT drives the GC, the heap goal is (GOMEMLIMIT - non-heap) x 0.97, about 0.93 of GOMEMLIMIT, and heap objects climb to it before every collection. A 0.9 threshold therefore rejects queries before each GC cycle can free its garbage, and the threshold cannot be moved above the GC goal without also moving the GC goal, because both scale with GOMEMLIMIT. Add -resource-monitor.heap-limit with two values: - gomemlimit (default): divide by GOMEMLIMIT, as today. - container: divide by the container memory limit, read from cgroups with github.com/KimMachineGun/automemlimit (memlimit.FromCgroup), which handles cgroup v1, v2 and nested hierarchies. With container, heap_utilization thresholds are a fraction of pod memory, so GOMEMLIMIT (where the GC runs) and the rejection threshold can be set independently, e.g. GC goal < threshold < pod limit. If the container memory limit cannot be read, the monitor logs a warning and reports a heap utilization of 0, so heap-based rejection and eviction stay off rather than acting on the wrong limit, and the pod still starts. CPU-based limits are unaffected. Signed-off-by: Ahmed Hassan <afayek@amazon.com>
Signed-off-by: Ahmed Hassan <afayek@amazon.com>
Signed-off-by: Ahmed Hassan <afayek@amazon.com>
Signed-off-by: Ahmed Hassan <afayek@amazon.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does:
The resource monitor divides heap objects by GOMEMLIMIT, so a heap rejection threshold is a fraction of the GC's own target. When GOMEMLIMIT drives the GC, the heap goal is
(GOMEMLIMIT - non-heap) x 0.97, about 0.93 of GOMEMLIMIT, and heap objects climb to that goal before every collection. Aheap_utilization: 0.9threshold therefore rejects queries before each GC cycle can free its garbage. The threshold cannot be moved above the GC goal without also moving the goal, because both scale with GOMEMLIMIT.This PR adds the experimental
-resource-monitor.heap-limit(resource_monitor.heap_limit):gomemlimit(default): divide by GOMEMLIMIT. No behaviour change.container: divide by the container memory limit, read from cgroups.With
container, heap thresholds are a fraction of the container memory limit, so GOMEMLIMIT and the rejection line can be set independently: GC goal < rejection line < container limit. The setting applies to every user of the resource monitor's heap value: ingester and store-gateway rejection, and querier eviction.If
containeris set and the limit cannot be read (no memory limit, not in a cgroup), the monitor logs a warning and reports heap utilization 0. Heap-based rejection and eviction stay off rather than acting on the wrong limit, and the process still starts. CPU-based limits are unaffected.New dependency:
github.com/KimMachineGun/automemlimitv1.0.2 (MIT), formemlimit.FromCgroup(). It handles cgroup v1, v2 and nested hierarchies through/proc/self/mountinfoand/proc/self/cgroup, so Cortex does not carry its own cgroup parser. Prometheus uses the same library and version to derive GOMEMLIMIT from the container memory limit (--auto-gomemlimit, on by default): see the import incmd/prometheus/main.goandgo.mod. It brings ingithub.com/pbnjay/memory(BSD-3-Clause), also a Prometheus dependency. Both are vendored.Which issue(s) this PR fixes:
None
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]docs/configuration/v1-guarantees.mdupdated if this PR introduces experimental flags