Skip to content

perf(component-build): keep cache mounts out of the checkout, save them every S3 build - #402

Merged
JesperTerkelsen merged 2 commits into
mainfrom
perf/cache-mounts-outside-checkout
Nov 15, 2026
Merged

JesperTerkelsen merged 2 commits into
mainfrom
perf/cache-mounts-outside-checkout

Conversation

@JesperTerkelsen

@JesperTerkelsen JesperTerkelsen commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

🏭 Factory Context
Session: Open in Factory
Requested by: @JesperTerkelsen

Intent

ARC image builds restore the Dockerfile cache mounts into the checkout, so any repo whose Dockerfile does COPY . . without a .dockerignore ships the whole cache as build context (1.8 GB for infra-portal, see this 13-minute deploy). This restores them into the runner's temp dir instead, and on the S3 backend saves them every build so the compile cache stays fresh.

Decisions: S3 builds now save ~1 GB of cache on every build
  • On S3 the key ends in the commit SHA, so every build misses the primary key, extracts the cache mounts and saves them; the next build restores the newest one saved for the Dockerfile through the existing prefix restore key. Costs an extract and upload per build, but infra-portal's go build took ~130 s with the stale cache against ~11 s with a fresh one (not discussed).
  • The actions/cache backend keeps the lockfile-only key, since per-commit saves would churn GitHub's 10 GB cache quota.
  • infra-portal also gets its own .dockerignore (monta-app/infra-portal#1501); this fixes every other caller without one.
Verified: actionlint passes; warm-cache Go build 11 s vs 130 s in CI
  • actionlint on component-build.yml passes.
  • infra-portal backend locally: with a cache from the previous build, a one-line change rebuilt go build in 11.1 s; the CI run with the cache last saved on 2026-10-30 (last go.sum change) took 129.6 s.

Gaps

  • Not run on a real ARC build: the first build after merge saves under the new key; the second should show a short go build and a Post step that extracts and uploads the caches. Watch that Post step's time against the saved compile time.
  • Per-commit entries grow the monta-github-ci-cache bucket; I didn't check its lifecycle rule.
  • Calling repos pick this up at @main on their next build; cache entries saved before it stay valid, since the restore keys still match them.
Thermo-nuclear review: 1 finding, 1 fixed

Review of 6309491

# Finding Outcome
1 component-build.yml:160: a second restore key repeating the lockfile hash, which the prefix key already covers (newest match wins) Fixed in 6309491.
  • scratch-dir moves to runner.temp with the cache dir, so cache-dance's extract can still rename the scratch copy into place on the same filesystem.

@JesperTerkelsen
JesperTerkelsen marked this pull request as ready for review November 14, 2026 21:30
@JesperTerkelsen
JesperTerkelsen requested a review from a team as a code owner November 14, 2026 21:30
@JesperTerkelsen
JesperTerkelsen requested review from sudheer-monta and removed request for a team November 14, 2026 21:30
@JesperTerkelsen
JesperTerkelsen merged commit ddc754a into main Nov 15, 2026
1 check passed
@JesperTerkelsen
JesperTerkelsen deleted the perf/cache-mounts-outside-checkout branch November 15, 2026 05:28
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