You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ifv, ok:=s.MemoryStats.Stats[inactiveFileKeyName]; ok {
ifworkingSet<v {
workingSet=0
} else {
workingSet-=v
}
}
ret.Memory.WorkingSet=workingSet
Usage
MaxUsage
FailCnt
Cache
RSS
Swap
MappedFile
WorkingSet - this is usage - inactive_file
In our case, we'd like more detailed metrics. We find that working set is often over what we want to account for (#3081 is one example), because, to quote a colleague:
container_memory_working_set_bytes is not what the OOM killer uses, but it is a better leading indicator of OOM risk than just the plain container_memory_usage_bytes. As long as the container's cgroup still has evictable filesystem cache pages, it will try hard to avoid killing processes, and container_memory_working_set_bytes subtracts some (but not all) of those pages.
A bit more about "evictable":
File pages in the "active" list are not evictable... until they get demoted back down to the "inactive" list. When the cgroup is starving for memory and needs to free a page (e.g. to satisfy a process requesting anonymous memory), it can shrink the total number of filesystem cache pages, and then the normal mechanism of demoting pages from the "active" list to the "inactive" list allows those previously unevictable pages to become eviction candidates the next time. There are only a few special cases where file-backed pages tend to not be evictable, which is why when we see an OOM kill event, the kernel's verbose logs for that kill typically show that most of the memory was anonymous, not file-backed.
So from the perspective of the container_memory_working_set_bytes metric, as memory pressure causes the container to shrink its number of file-backed pages to make room for more anonymous memory, both the "active" and "inactive" lists of file-backed pages will tend to shrink. So before reaching OOMK, the metric should be dominated by anonymous memory, and the lead-up to that point should be more or less gradual depending on the relative sizes of the active vs. inactive lists of filesystem cache pages.
I lean towards treating just the anonymous memory by itself as a saturation metric, since on swapless hosts it is guaranteed to be unevictable.
(Side note: we'd like to use RSS instead of WSS, but then we run into issues with programs that use MADV_FREE. Go dropped this in golang/go#42330, but programs in other languages may still use this, which inflates RSS above what might be expected.)
The text was updated successfully, but these errors were encountered:
This seems similar to #2634; in our case, if we had LazyFree exposed, we could also take RSS - LazyFree to get the value we're interested in. It looks like #2767 went stale, though.
Currently, cAdvisor reports the following memory stats:
cadvisor/container/libcontainer/handler.go
Lines 802 to 844 in ce07bb2
usage - inactive_file
In our case, we'd like more detailed metrics. We find that working set is often over what we want to account for (#3081 is one example), because, to quote a colleague:
memory.stat
includesactive_anon
,inactive_anon
,active_file
, andinactive_file
(among others) but these are not exposed by cAdvisor currently: https://docs.kernel.org/admin-guide/cgroup-v1/memory.html#stat-fileWould you accept a patch to add those?
(Side note: we'd like to use RSS instead of WSS, but then we run into issues with programs that use
MADV_FREE
. Go dropped this in golang/go#42330, but programs in other languages may still use this, which inflates RSS above what might be expected.)The text was updated successfully, but these errors were encountered: