Skip to content

Reuse sandbox containers across build commands#127

Merged
GuillaumeGomez merged 2 commits into
rust-lang:mainfrom
syphar:reuse-container
May 14, 2026
Merged

Reuse sandbox containers across build commands#127
GuillaumeGomez merged 2 commits into
rust-lang:mainfrom
syphar:reuse-container

Conversation

@syphar
Copy link
Copy Markdown
Member

@syphar syphar commented May 4, 2026

Sorry, this is a bigger one. Happy to walk you through the ideas / changes, happy to discuss them.

Doing some tests I realised that only docker create and docker rm sometimes takes 5s, 10s, or 40s. Also very often it's <100ms).

Docs.rs is running multiple commands:

  1. coverage
  2. docs
  3. json

for each target.

This leads me to the assumption that this could be a major reason why there is such a big difference between local host-builds and docs.rs container builds for the same crate. In some examples I checked the numbers roughly fit, #125 will give us more data when added to docs.rs & deployed.

Between these commands, we don't need a new container, we can just run more commands in the same container.

This refactors rustwide to make this possible. I think the new design is a better one, so I made this a breaking change.

The idea is:

  • SandboxBuilder just creates the Container
  • on the Container we can then run one or more commands.

The previous ProcessStatistics had to go too, and are SandboxStatistics now (= per-container, not per-command/call). Our source in docker is exactly that, and the API should reflect it. This is fine for the optimized docs.rs usage.

testing

@syphar syphar self-assigned this May 4, 2026
@syphar syphar changed the title WIP: reuse containers across build commands Reuse sandbox containers across build commands May 4, 2026
@syphar syphar force-pushed the reuse-container branch from d4f17a0 to 528a806 Compare May 13, 2026 04:00
@syphar syphar marked this pull request as ready for review May 13, 2026 04:00
@syphar syphar requested a review from GuillaumeGomez May 13, 2026 04:00
Comment thread src/cmd/sandbox.rs Outdated
Comment thread src/cmd/sandbox.rs Outdated
Comment thread src/cmd/sandbox.rs Outdated
Comment thread CHANGELOG.md
Copy link
Copy Markdown
Member

@GuillaumeGomez GuillaumeGomez left a comment

Choose a reason for hiding this comment

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

Just nits, the rest looks good to me, thanks!

@syphar syphar requested a review from GuillaumeGomez May 14, 2026 07:35
@GuillaumeGomez
Copy link
Copy Markdown
Member

Thanks!

@GuillaumeGomez GuillaumeGomez merged commit 9202e52 into rust-lang:main May 14, 2026
9 checks passed
@syphar syphar deleted the reuse-container branch May 14, 2026 15:48
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