Skip to content

improve performance of reading sandbox stats (oom, peak memory)#133

Open
syphar wants to merge 1 commit into
rust-lang:mainfrom
syphar:direct-cgroup
Open

improve performance of reading sandbox stats (oom, peak memory)#133
syphar wants to merge 1 commit into
rust-lang:mainfrom
syphar:direct-cgroup

Conversation

@syphar
Copy link
Copy Markdown
Member

@syphar syphar commented May 17, 2026

after each command in the build we see (and need) this:
image

most exec cat calls 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 cat approach 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 Container

Generally: I think most randomly show things are i/o bound, and increasing the bandwidth / iops will hopefully help.

@syphar syphar self-assigned this May 17, 2026
@syphar syphar changed the title WIP: improve performance of reading sandbox stats (oom, peak memory) improve performance of reading sandbox stats (oom, peak memory) May 18, 2026
@syphar syphar marked this pull request as ready for review May 18, 2026 06:05
@syphar syphar requested a review from GuillaumeGomez May 19, 2026 11:35
Comment thread src/cmd/sandbox/docker.rs
/// Most of the time: v2
/// on old systems like the docs.rs builder: v1
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(super) enum CgroupVersion {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of implementing all that, why not using crates with this feature like sysinfo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants