liveBook · Manning

Sccache

As explained in Code Like a Pro in Rust

sccache is a compiler cache that stores and reuses compilation results.

sccache is a general-purpose compiler cache for Rust projects. It stores unchanged compiler outputs so repeated builds avoid recompiling previously compiled code. section 3.5

Use sccache when repeated compilation time affects local development or CI/CD:

  • Install it with Cargo, then expose it to Cargo through the RUSTC_WRAPPER environment variable. section 3.5.1
  • Use local storage by default, or configure networked S3, Redis, or Memcached-compatible backends for shared build caching. section 3.5.2
  • Expect benefits only after compilation results exist; sccache does not accelerate a completely fresh build. section 3.5
$ cargo install sccache

Install sccache with Cargo before configuring it as Cargo’s rustc wrapper. section 3.5.1

$ export SCCACHE_REDIS=redis://10.10.10.10/sccache    #1

Point sccache at a Redis backend by setting SCCACHE_REDIS to a Redis address. section 3.5.2

Measured local improvement

A clean dryoc build took 8.891 seconds normally and 5.839 seconds with sccache enabled, making the uncached run 52% slower. section 3.5

How Code Like a Pro in Rust covers it

How deep it goes
Explains cached compiler outputs, installation, wrapper integration, storage backends, and fresh-build limits without detailing cache internals.
Examples
Measures a dryoc build with and without sccache and demonstrates Cargo installation, wrapper, and Redis configuration commands.
What it assumes
Assumes familiarity with Rust projects and Cargo, while teaching installation and compiler-wrapper configuration directly.
What you can do after
Operate/configure it through Cargo’s rustc wrapper, local storage, or a supported network backend.
How it connects
Connects sccache to Rust, rustc, Cargo, compiler caching, CI/CD, S3, Redis, and Memcached.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Code Like a Pro in Rust. The section links point to the parts of the book it draws on.