Skip to content

Commit 4e55c24

Browse files
authored
Merge pull request #2247 from marcoieni/ci-cache
improve CI cache docs
2 parents 03a1548 + 8a6fd47 commit 4e55c24

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/tests/ci.md

+20-4
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ Our CI workflow uses various caching mechanisms, mainly for two things:
322322
### Docker images caching
323323

324324
The Docker images we use to run most of the Linux-based builders take a *long*
325-
time to fully build. To speed up the build, we cache it using [Docker registry
325+
time to fully build. To speed up the build, we cache them using [Docker registry
326326
caching], with the intermediate artifacts being stored on [ghcr.io]. We also
327327
push the built Docker images to ghcr, so that they can be reused by other tools
328328
(rustup) or by developers running the Docker build locally (to speed up their
@@ -334,16 +334,32 @@ override the cache for the others. Instead, we store the images under different
334334
tags, identifying them with a custom hash made from the contents of all the
335335
Dockerfiles and related scripts.
336336

337+
The CI calculates a hash key, so that the cache of a Docker image is
338+
invalidated if one of the following changes:
339+
340+
- Dockerfile
341+
- Files copied into the Docker image in the Dockerfile
342+
- The architecture of the GitHub runner (x86 or ARM)
343+
337344
[ghcr.io]: https://github.com/rust-lang-ci/rust/pkgs/container/rust-ci
338345
[Docker registry caching]: https://docs.docker.com/build/cache/backends/registry/
339346

340347
### LLVM caching with sccache
341348

342349
We build some C/C++ stuff in various CI jobs, and we rely on [sccache] to cache
343350
the intermediate LLVM artifacts. Sccache is a distributed ccache developed by
344-
Mozilla, which can use an object storage bucket as the storage backend. In our
345-
case, the artefacts are uploaded to an S3 bucket that we control
346-
(`rust-lang-ci-sccache2`).
351+
Mozilla, which can use an object storage bucket as the storage backend.
352+
353+
With sccache there's no need to calculate the hash key ourselves. Sccache
354+
invalidates the cache automatically when it detects changes to relevant inputs,
355+
such as the source code, the version of the compiler, and important environment
356+
variables.
357+
So we just pass the sccache wrapper on top of cargo and sccache does the rest.
358+
359+
We store the persistent artifacts on the S3 bucket `rust-lang-ci-sccache2`. So
360+
when the CI runs, if sccache sees that LLVM is being compiled with the same C/C++
361+
compiler and the LLVM source code is the same, sccache retrieves the individual
362+
compiled translation units from S3.
347363

348364
[sccache]: https://github.com/mozilla/sccache
349365

0 commit comments

Comments
 (0)