improve performance of reading sandbox stats (oom, peak memory)#133
Merged
Conversation
| /// Most of the time: v2 | ||
| /// on old systems like the docs.rs builder: v1 | ||
| #[derive(Clone, Copy, Debug, PartialEq, Eq)] | ||
| pub(super) enum CgroupVersion { |
Member
There was a problem hiding this comment.
Instead of implementing all that, why not using crates with this feature like sysinfo?
Member
Author
There was a problem hiding this comment.
I did check two crates, they either didn't provide these specific metrics, or you couldn't get them for existing cgroups (only when the library also created them).
I'll check once more for crates. Sysinfo wasn't on the initial list.
Member
Author
There was a problem hiding this comment.
cgroups-rshas the needed functionality, is badly documented, and has compile errors when building on non-linux (inconsistent gating of the linux specific logic). could probably make it work when gating it to linux in rustwide itself ( annoying when doing this on my machine). Or trying to fix the library itself, using a git fork in rustwide, or adding a patch if it's small.- in
sysinfothe struct is calledCgroupLimits, but the names (and the used stats) don't look like limits, but the current values? In any case, the memory-peak is missing, and the oom counter too. Is that something you would see there?
what do you think?
I feel like with a stable cgroup
Member
Author
There was a problem hiding this comment.
checking more libraries later, you can point me to the points you had in mind
Member
There was a problem hiding this comment.
Seems like sysinfo will need an update. For now let's go. :)
GuillaumeGomez
approved these changes
May 20, 2026
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.
after each command in the build we see (and need) this:

most
exec catcalls as <100 ms, but I regularly see calls between 2 and 10 seconds. Which is quite a waste, when we see that we currently do 4 calls after each container command (two for oom, two for memory peak).First optimization was that we remember which cgroup version we have, so then we can save one call in the later checks.
Then I discovered that we also can get the same information directly in special files from the host. So I added this. From what I see, the locations likely speficic to the used setup / engine, so I left the
exec catapproach in. I checked that the "fast" way would be used by docs.rs.I don't like the added complexity, but the performance impact will likely be noticeable.
While we're on it I extracted the bigger cgroup stats code into a new module, container lifetime stuff stays in
ContainerGenerally: I think most randomly show things are i/o bound, and increasing the bandwidth / iops will hopefully help.