Skip to content

Fargate: cap cargo's jobs in a config file, not the environment (rust-cache key) - #37

Merged
sodre merged 1 commit into
mainfrom
land/cargo-config
Nov 14, 2026
Merged

sodre merged 1 commit into
mainfrom
land/cargo-config

Conversation

@sodre

@sodre sodre commented Nov 14, 2026

Copy link
Copy Markdown
Member

Summary

A Fargate job never hit the Rust cache an EC2 job saved. Swatinem/rust-cache hashes CARGO*, CC*, CFLAGS*, CXX*, CMAKE* and RUST* environment variables into its key (source), and Fargate tasks set CARGO_BUILD_JOBS. The cap on cargo's parallelism moves from the environment into a config file.

 Fargate entrypoint (ci-runner-idle-exit)
+  CI_RUNNER_VCPUS=<n> set → write /home/runner/.cargo/config.toml: [build] jobs = <n>
+                            (an existing file is kept; a bad value warns and writes nothing)
 launcher RunTask env (integration branch, #32)
-  CARGO_BUILD_JOBS=<n>, CMAKE_BUILD_PARALLEL_LEVEL=<n>, MAKEFLAGS=-j<n>
+  CI_RUNNER_VCPUS=<n>, MAKEFLAGS=-j<n>

Cargo reads .cargo/config.toml from every ancestor of the working directory, so the file covers any checkout under /home/runner/_work. rust-cache only hashes config files inside the workspace, so this one leaves the key alone.

Evidence

  • Before (live): zae-zcm's Fargate run computed rust-cache key …-ef9743d9-…, against EC2's …-2fd77104-…. The first wave built cold.
  • After: image/smoke.sh covers five cases (no variable, the file's contents, its owner runner, an existing file kept, a bad value). It passed on amd64 and arm64: https://github.com/zeroae/ci-runner/actions/runs/43560324849.
  • Still to measure: a Fargate job hitting EC2's cache, which needs this image plus the launcher change deployed.

Merge Danger

Door: two-way.

Blast Radius: Fargate only.

EC2 doesn't use this entrypoint. Until the launcher change deploys, the old environment variables still apply, and the file is not written (no CI_RUNNER_VCPUS).

Part of #18 (#29).

🤖 Generated with Claude Code

With CI_RUNNER_VCPUS set, ci-runner-idle-exit writes
/home/runner/.cargo/config.toml with [build] jobs = <n>, leaving an
existing file alone. A CARGO_BUILD_JOBS in the environment changes
Swatinem/rust-cache's key (it hashes every CARGO*, CC*, CFLAGS*, CXX*,
CMAKE* and RUST* variable), so a Fargate job never hit the cache an EC2
job saved. Cargo reads .cargo/config.toml from every ancestor of its
working directory, so the file reaches every checkout under _work.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sodre
sodre merged commit 7b4ce3c into main Nov 14, 2026
5 checks passed
@sodre
sodre deleted the land/cargo-config branch November 14, 2026 06:25
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.

1 participant