/build-system:sccache-updatefrom build-system
Bumps the sccache version used by Firefox CI, measures build-time impact on try, and investigates cache misses including Rust cache key differences.
Ships in build-system. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
We maintain sccache. We can modify and update this project if needed.
sccache is fetched from git in taskcluster/kinds/fetch/toolchains.yml, entry
sccache:. Change the comment and the revision: to the release:
# 0.20.0 release
revision: <sha>
Resolve the tag to the commit it points at, not the annotated tag object.
Use the ^{} line:
git ls-remote https://github.com/mozilla/sccache 'refs/tags/v0.20.0*'
The toolchain tasks that build it are in taskcluster/kinds/toolchain/sccache.yml.
If the release raises its minimum Rust version, linux64-rust-toolchain may also
need a bump. A failing TL(sccache) task on try is the signal.
Don't hesitate to propose to the developer to open a bug.
Bug NNNNNNN - Update sccache to X.Y.Z r?#firefox-build-system-reviewers
For review, submit like any other commits
Before pushing, read the release notes of every version between the old and
the new one (https://api.github.com/repos/mozilla/sccache/releases/tags/vX.Y.Z).
Look for changes to what is hashed: they change cache keys, so every build
misses until the cache refills. Also look for changes to the storage backends
(GCS, HTTP, DNS, auth), which affect the time of each hit.
To check for a cache-namespace change, compare
CACHE_VERSION in src/compiler/compiler.rs between the tags:
git grep -h 'const CACHE_VERSION' <tag> -- src. A changed value invalidates
the compiler cache, but an unchanged value does not guarantee cache hits:
changes to hashed inputs can still produce new keys. The second CACHE_VERSION
belongs to the preprocessor cache (direct mode), which Firefox CI doesn't use.
Push the patched revision and its parent with identical task selections.
mach try compare is fzf-interactive only, so push twice by hand:
Q=(-q '^build-linux64/opt$' -q '^build-win64/opt$' -q '^build-macosx64/opt$' --rebuild 3)
./mach try fuzzy "${Q[@]}" -m "sccache X.Y.Z perf: NEW (bug NNNNNNN)" > artifacts/try-new.txt 2>&1
git checkout --detach HEAD^
./mach try fuzzy "${Q[@]}" -m "sccache X.Y.Z perf: BASE (bug NNNNNNN)" > artifacts/try-base.txt 2>&1
git checkout - # back to the branch
When chaining checkouts and pushes in one shell command, check after each
git checkout that HEAD is the expected commit, and stop otherwise. Editors
and other tools run git commands in the background, and on a tree this size
.git/index.lock can stay held for several seconds. A failed checkout then
pushes whatever branch you were on, under the wrong label. Wait for the lock
to go away and retry, but never delete it: another git process may be
writing the index.
Check the selection first with --no-push. Each output file ends with a
Treeherder URL carrying a landoCommitID.
Push every revision being compared within the same few minutes, and push again any revision you reuse from an earlier comparison. Pushes made hours apart get different workers, network conditions and cache states, and the differences look like results.
To measure another change on top, such as building sccache with PGO, push a
third revision with the same selection. Push only the commits being measured:
pushes contain every commit in the stack, and the decision task drops all tasks
when a commit message contains DONTBUILD, as skill commits often do. Put
the commits on a detached HEAD at the NEW revision:
git checkout --detach <NEW commit>
git cherry-pick <commits to measure>
./mach try fuzzy "${Q[@]}" -m "sccache X.Y.Z perf: PGO (bug NNNNNNN)" > artifacts/try-pgo.txt 2>&1
git checkout -
Lando queues try pushes, sometimes for several minutes. The job at
https://lando.moz.tools/landing_jobs/<landoCommitID>/ stays SUBMITTED until
it reaches LANDED and its commit_id holds the try revision. Treeherder and the
Taskcluster index take a few more minutes to list the push. Use that revision
from then on: treeherder-cli <landoCommitID> can fail with error decoding response body even after the job has landed.
curl -s https://lando.moz.tools/landing_jobs/<landoCommitID>/ | python3 -I -c \
'import json,sys; d=json.load(sys.stdin); print(d["status"], d["commit_id"])'
treeherder-cli <rev> --filter '^build-' --watch
Every build task uploads public/cidata/sccache-stats.json, the output of
sccache --show-stats as JSON. It holds the sccache version, hits and misses
per language, cache read/write durations, the reasons requests weren't cacheable,
and error counters. Use it rather than scraping logs.
scripts/compare_sccache_stats.py (in this skill's base directory) finds every build task of both pushes,
including rebuilds, by listing the decision task's group. It fetches the
artifact for each one and prints per-task and per-label median tables, ready to
paste into a bug:
python3 -I <skill-dir>/scripts/compare_sccache_stats.py \
base=<rev> new=<rev> [pgo=<rev> ...] > artifacts/sccache-compare.md
Deltas are against the first push. Tasks with a hit rate under 95% are left out
of the medians and counted in runs as kept/total. --min-hit-rate changes the
threshold.
--filter <regex> changes the task selection (default ^build-). --json
dumps the raw rows. The per-label index routes
(gecko.v2.try.revision.<rev>.firefox.<platform>) keep only the latest task, so
don't use them to find rebuilds.
Read-hit and compile times are summed over all parallel compile jobs. They are CPU-side totals, not wall clock. "Per hit" divides the read-hit time by the number of hits. It includes the round trip to the cache bucket, so a gain in sccache's own CPU time, such as the 3-5% upstream reports for PGO, is easily lost in network noise. Only a large change in it is meaningful. Task duration covers the whole task, including checkout and packaging.
The win64 and macOS builds are cross-compiled on Linux workers and run the
linux64-sccache binary, like linux64. All three platforms measure the same
sccache binary against different workloads, so a change to that one binary,
such as PGO, shows on all of them.
Check the version column first. Every NEW task must report the new
version, otherwise the build didn't pick up the new toolchain.
Compare per platform, on full-cache builds only. If the new version changes
cache keys, every task that starts before one build has filled the cache
misses. That includes all --rebuild copies and every other push using the
same version (NEW and PGO, say), because they run at the same time. With
only one or two full-cache runs left, push again once the cache is full,
rather than drawing conclusions.
Task duration is dominated by things unrelated to sccache. Before comparing, check each task for:
applying clone bundle and spends about 2 minutes on a full clone,
against 15s otherwise;gkrust cache miss ([gkrust]: Cache miss in sccache.log), which
adds about 10 minutes;package-tests, an automation sub-step of mach build (log lines
prefixed package-tests> ), which takes 30 to 85s depending on how long
download_wpt_manifest takes to load and update the WPT manifest.Compare the compilation part of the build step instead: from
mach --log-no-times build to the first automation sub-step (the first line
prefixed <step>> , such as package-tests> or upload> ), and only on
tasks with a gkrust hit. Its noise is about ±4%. Only report a difference
larger than that, and only if all runs agree on its direction.
Look at the "misses by compiler" column, not just the hit rate. A hit rate
in the high 90s can hide one compiler missing heavily: sccache 0.19.0
missed 46-223 Rust compilations per run with a 96-99% hit rate, and builds
took three times as long. A version can change some keys without bumping
CACHE_VERSION. --rebuild copies run at the same time, not one after
another, so all of them miss together on a new key. That isn't proof of an
unstable key.
To see what missed and why, read public/cidata/sccache.log from the build
task. It's at debug level: each compilation logs
[<crate or object>]: Hash key: <hex>, then Cache hit or Cache miss.
List the misses with:
grep 'Cache miss in' sccache.log | grep -v conftest \
| sed -E 's/^\[[^]]*\] \[([^]]+)\]: Cache miss.*/\1/' | sort | uniq -c
Compare the Hash key of one missed crate across runs. The same key in
every run means a cold cache. A key that differs between runs of the same
revision means an unstable key. For Rust, the key covers the dependencies,
so one crate with a new key makes everything that depends on it miss too:
the earliest misses in the log are the root ones.
Report the cold builds separately: their hit rate and duration show the one-off spike to expect once the change lands. Note that in the bug.
"Per hit" is the wall time of storage.get in the sccache daemon,
measured on its async runtime. It includes time waiting to be scheduled
behind other work on that runtime, so it can rise while build durations
don't move. Weigh it against durations before calling it a regression. DNS
only matters for new connections: the daemon keeps one pooled HTTP client,
so a build does about as many lookups as it has concurrent requests, not one
per hit.
A per-hit time difference measured while other pushes are filling the cache is not reliable. Confirm it with a second BASE and NEW push on a full cache before reporting it as a regression.
Post a table in the bug: platform, BASE median, NEW median, delta, hit rates.
Don't expect gains from making sccache itself faster. Building the
linux64-sccache toolchain with PGO, trained on local and GCS workloads with
clang, clang-cl and rustc, was measured in November 2026: no difference on
build time nor on generate_hash_key time. Per compilation, the time goes
to the preprocessor (clang -E, 110-250ms per C++ file), to reading and
hashing Rust dependencies, and to the round trip to the bucket.
To find which release introduced a change, bisect between releases first:
push the middle release (a [try only] commit setting revision: to its
tag's commit) together with BASE and NEW, on one platform with more
--rebuild runs. All three platforms run the same linux64-sccache binary,
so one platform with 6 runs gives a better median than three with 2.
To test whether one upstream change causes a difference, such as a revert or a fix not yet released, build sccache from a branch in your GitHub fork of mozilla/sccache:
git revert <sha> usually conflicts on Cargo.lock. Keep the
release's lockfile (git checkout --ours Cargo.lock), then run
cargo metadata --format-version 1 > /dev/null. That adds the missing
crates without upgrading the others. Check that git diff Cargo.lock
only adds packages.git ls-remote https://github.com/<user>/sccache refs/heads/<branch>.sccache: fetch in
taskcluster/kinds/fetch/toolchains.yml at the fork: set repo: to the
fork's URL and revision: to that SHA. Commit it as
Bug NNNNNNN - [try only] ... and push with the same task selection as the
other runs. Never land that commit.Each GCP region has its own bucket, sccache-l<level>-<region>; the region is
in the "region" field at the top of the task log. When a crate's key differs
between regions, every crate depending on it differs too, up to gkrust, and
each region has to fill its own copy: a gkrust miss costs about 10 minutes.
The usual cause is a crate whose compilation is not deterministic: the same
inputs, and so the same key, give different outputs, and each bucket keeps the
first variant stored. Bug 2098857 added a check for this: the reproduced and
shippable builds publish target.rust-artifacts.txt, the sha256 of every
rlib, rmeta file and proc-macro library, and the
diff-reproducible-<platform>-rust-artifacts tasks diff them on
mozilla-central. Neither build uses sccache, so a difference names the crate.
Look at those tasks first, or run one on try (it brings in the PGO chain, so
expect a few hours):
./mach try fuzzy -q "'diff-reproducible-linux64-rust-artifacts"
When a root crate differs, all the crates depending on it differ too: the earliest one in the dependency order is the cause. Use the steps below when the check is green but keys still differ, such as an input that sccache doesn't hash, or to confirm what a bucket holds.
Compare the gkrust key across the tasks of one push and platform:
grep -m1 '\[gkrust\]: Hash key' sccache.log. The same key within a region
and a different one between regions means a divergence.
Find where it starts with one sccache.log from each region:
python3 -I <skill-dir>/scripts/rust_key_roots.py east/sccache.log central/sccache.log
It prints the root crates: their key differs although all their --extern
dependencies have the same key. Either a dependency's content differs under
an identical key, or an input sccache hashes without logging it differs,
such as a CARGO_* variable.
To tell which, download the entries of the root and of its dependencies from
both buckets, with a [try only] commit running only
toolchain-linux64-sccache. Give that task the scope
assume:project:taskcluster:gecko:level-{level}-sccache-buckets and
worker: taskcluster-proxy: true, and fetch:
http://taskcluster/auth/v1/gcp/credentials/sccache-3/<bucket>@sccache-3.iam.gserviceaccount.com
(northamerica shortened to na in the account name, see
build/mozconfig.cache);https://storage.googleapis.com/storage/v1/b/<bucket>/o/<a%2Fb%2Fc%2Fkey>?alt=media,
where a, b and c are the first three characters of the key.Publish the objects as the task's artifact. An entry is a zip whose members are each zstd-compressed: compare the decompressed members, since the zips themselves differ by their metadata.
Reproduce locally with the rustc version CI uses
(rustup toolchain install <version>). Build inside the Firefox workspace,
which carries the [patch.crates-io] overrides:
.cargo/config.toml.in, with an absolute path
for the vendored directory and without the @REPLACE_NAME@ section;cargo +<version> build -p <workspace member> --release --offline --config <that file> --target-dir /tmp/<dir>, where the member enables
the same features as in CI (cargo tree -e features -i <crate>);cargo clean -p <crate>) between builds and compare the
.rlib and .rmeta hashes. Restore Cargo.lock afterwards: a
--config 'patch...' test rewrites it.If the outputs differ, compare RUSTC_BOOTSTRAP=1 cargo rustc -p <crate> -- -Zunpretty=expanded across two runs. A textual difference points at the
order of a macro's output. Identical text with .rmeta files differing only
in the 16 bytes after the target triple (the crate's SVH) points at
#[cfg(...)] attributes emitted in a varying order: rustc strips them during
expansion but hashes them into the SVH (rust-lang/rust#89904).
The usual cause is a proc-macro iterating a HashMap or HashSet. Known
cases, both patched in tree in bug 2098857:
multiversion-macros 0.8, used by encoding_rs with its std feature,
made about 80 crates differ, up to gkrust (fixed upstream in 0.9 by
calebzulawski/multiversion#50, which depends on syn 3);uniffi_internal_macros 0.32, used by uniffi_bindgen on the host,
made uniffi_bindgen, uniffi and uniffi_build differ (fixed upstream
in 0.33).When upgrading either crate past those versions, drop its patch.
Update the crate, or patch it in tree the way bug 2069639 patched cc:
edit third_party/rust/<crate>, add a [patch.crates-io] entry with a path
in the root Cargo.toml, drop the crate's source and checksum lines from
Cargo.lock, add a [policy.<crate>] with audit-as-crates-io = true to
supply-chain/config.toml, and run ./mach cargo vet check. Then run the
rust-artifacts diff on try to confirm it is green.
The other diffoscope reproducibility tasks don't catch this: they compare the
final artifacts, which the SVH never reaches, and host tools such as
uniffi_bindgen don't ship.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub mozilla/firefox-aidev-plugins --plugin build-systemOther plugins' skills for the same job