Cgroup cpu usage#1029
Conversation
|
|
…confirm that RealSysInfo uses them when running in a cgroup. Add tiny shell script to help with cross compiling and running the tests in a container via docker.
…he directories to make sure I get it right next time if this isn't right
…all the executable by the filename that was used to create it.
| //there won't be a cgroup cpu usage if there is no limit applied to the cgroup | ||
| //or if an error is encountered when reading cpu.stat or cpu.max | ||
| //in these cases, fallback to global cpu usage |
There was a problem hiding this comment.
Nit: I'm vaguely surprised this isn't a cargo fmt thing, but, the lack a space after your // freaks me out
| #[test] | ||
| fn cgroup_realsysinfo_uses_cgroup_limits_cpu() { | ||
| let sys_info = RealSysInfo::new(); | ||
| let cgroup_info = CGroupCpuInfo::new(CgroupV2CpuFileSystem); |
There was a problem hiding this comment.
Honestly this is one of the few spots where I don't like Rust - really this should be an integ test. It could be its own binary and only run in CI. Having to have the skips in a unit test feels a little awkward, but having to pub all this or put it in its own crate is even stupider.
I don't have any actual suggestion here, just whining.
... Actually maybe I do - let's protect these with explicit env vars saying to run the tests. That way they also won't silently succeed when they're supposed to be able to read stuff but can't
There was a problem hiding this comment.
I actually had this as an integ test at first, but couldn't stomach adding the pub so I undid that and moved these to unit tests 😅.
Added the env var though!
Sushisource
left a comment
There was a problem hiding this comment.
Awesome! Thanks for the work on this
What was changed
Update RealSysInfo to read cgroupv2 CPU limits when the sysinfo crate has cgroup memory limits available.
Why?
When running in a container it's more appropriate to report the CPU usage as a factor of it's limit rather than the host system.
Checklist
Closes [Feature Request] Support CPU Cgroup Limits in Resource-based tuner / Confirm memory functionality #903
How was this tested:
docker-cgroup-tests.shto cross-compile tests and execute only cgroup tests via docker.