-
-
Notifications
You must be signed in to change notification settings - Fork 335
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
Free memory is wrong on Linux with gcroups v2 #1219
Comments
Is it the free memory of the system in which your container is running by any chance? Also, please show the code you're using. If you want to get cgroup information, you need to use cgroup_limits. |
@GuillaumeGomez the code we're using is here: https://github.com/getsentry/relay/blob/be87f135374b2c3ea941a7ec1bd236071d13db13/relay-server/src/services/health_check.rs#L273-L292 // Use the cgroup if available in case Relay is running in a container.
if let Some(cgroup) = self.system.cgroup_limits() {
Memory {
used: cgroup.total_memory.saturating_sub(cgroup.free_memory),
total: cgroup.total_memory,
}
} else {
Memory {
used: self.system.used_memory(),
total: self.system.total_memory(),
}
} |
Ok so you were using the correct code already and even already wrote a patch. Awesome! :) |
Do you know why that code was there in the first place (reading from |
I really don't know. I tried digging through the cgroup man pages and I have no clue what is correct. I wanna say no, since these are all system values and not necessarily relevant for the cgroup? Maybe you have an idea @gi0baro ? What we can do is test the fork and see if it reports similar/same values we get from Kubernetes. |
It'd be much appreciated. 👍 |
@GuillaumeGomez to my knowledge, and based on the information available at https://docs.kernel.org/admin-guide/cgroup-v2.html, I'm not a kernel dev nor expert, but IMHO the only value in |
Thanks for the information! Let's wait for @Dav1dde's tests results and then they'll update (or not depending on the results) their PR, then I'll merge it and make a new release. |
…3220) The memory health check is broken for cgroup v2, see GuillaumeGomez/sysinfo#1219 Switches to a fork until the upstream issue is fixed.
@GuillaumeGomez the results are in, a picture speaks more than a thousand words? This is the max memory usage of all our pods, top is reported from Kubernetes, the bottom is reported via sysinfo crate (with the patch from #1220 applied). It pretty much matches perfectly (purely empirical evidence). Also big thanks to @gi0baro he actually did the hard work, I just setup the metrics. |
system: Linux container based on
debian:bookworm-slim
sysinfo version: 0.30.6
The actual
cgroup
v2 readings deduct all the values in/sys/fs/cgroup/memory.stat
from available memory in these lines https://github.com/GuillaumeGomez/sysinfo/blob/master/src/unix/linux/system.rs#L560-L562This is causing wrong reporting on the available memory, as
memory.stat
includes values already counted inmemory.current
, plus values which are not inherent to available memory, eg:The free memory reported by sysinfo in this case is 425495718 which is clearly wrong.
I'm not sure why all
memory.stat
contents gets subtracted from the available memory.The text was updated successfully, but these errors were encountered: