Skip to content

build(nix): turn off incremental so sccache actually caches - #20

Merged
jamesaphoenix merged 1 commit into
jamesaphoenix:mainfrom
jakob1379:t3code/devshell-sccache-cache
Sep 21, 2026
Merged

jamesaphoenix merged 1 commit into
jamesaphoenix:mainfrom
jakob1379:t3code/devshell-sccache-cache

Conversation

@jakob1379

Copy link
Copy Markdown
Contributor

Problem

RUSTC_WRAPPER = "sccache" in the devshell has never cached a dev build. Cargo passes -C incremental=<dir> for the dev and test profiles, and sccache treats any rustc invocation carrying that flag as non-cacheable.

Verified against the devshell's own toolchain (rustc 1.94.0, sccache 0.17.0), same rustc args in all three calls:

plain (1st)    -> cache miss, stored
plain (2nd)    -> cache hit
-C incremental -> Non-cacheable call

The evidence in a working checkout is the target/debug/incremental tree — multiple GB per worktree, which only exists because incremental is on, which is exactly why nothing was reaching the cache.

Change

  • CARGO_INCREMENTAL = "0" — makes the existing wrapper live.
  • SCCACHE_CACHE_SIZE = "50G" — the 10G default is nearly filled by one worktree's dependency graph, so branches in flight were evicting each other.

Trade-off

Incremental wins on repeated rebuilds inside one checkout after a small edit. sccache wins on first builds across checkouts and branch switches. With 764 dependency crates and several worktrees in flight, the second dominates — and the deleted incremental trees pay back several GB per worktree.

Not benchmarked end to end: the non-cacheable classification is measured, the size of the speedup is not.

RUSTC_WRAPPER=sccache has been a no-op for every dev build: cargo passes
-C incremental for the dev and test profiles, and sccache classifies any
rustc call carrying that flag as non-cacheable. Verified against the
devshell's own toolchain — identical invocations cache and hit without
the flag, and report "non-cacheable call" with it.

With seven worktrees in flight the cross-worktree reuse of 760+ compiled
dependency crates is worth more than incremental relinking inside one of
them, and dropping incremental also reclaims the multi-GB
target/debug/incremental tree each worktree was carrying.

Raise the cache ceiling while here: the 10G default is nearly filled by a
single worktree's dependency graph, so concurrent branches were evicting
each other's entries.
@jamesaphoenix
jamesaphoenix merged commit dafc1e7 into jamesaphoenix:main Sep 21, 2026
1 check passed
@jakob1379
jakob1379 deleted the t3code/devshell-sccache-cache branch September 22, 2026 05:35
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