Skip to content

perf(build): share sccache across worktrees#2379

Merged
matthewgrossman merged 3 commits into
mainfrom
mgrossman/shared-sccache
Jul 21, 2026
Merged

perf(build): share sccache across worktrees#2379
matthewgrossman merged 3 commits into
mainfrom
mgrossman/shared-sccache

Conversation

@matthewgrossman

@matthewgrossman matthewgrossman commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Make the local sccache directory configurable per environment without changing
the existing CI fallback. Workstations can point SCCACHE_DIR at one shared
location, while CI can choose its own directory or remote backend.

Related Issue

None.

Changes

  • Preserve a non-empty SCCACHE_DIR supplied before mise runs.
  • Fall back to each worktree's existing .cache/sccache directory when the
    variable is unset, keeping current CI cache paths unchanged.
  • Keep Cargo output in each worktree's local target/ directory.
  • Document workstation configuration and the cross-worktree limitations of
    leaving SCCACHE_BASEDIRS unset.

Testing

  • mise run pre-commit passes
  • Confirmed an explicit SCCACHE_DIR reaches mise x subprocesses
    unchanged
  • Confirmed an unset SCCACHE_DIR resolves to the worktree-local
    .cache/sccache fallback
  • Built openshell-core from two worktrees at the same commit using an
    isolated shared sccache directory and separate Cargo target directories

Cache experiment

The experiment used sccache 0.14.0 with CARGO_INCREMENTAL=0, a fresh cache,
and a dedicated daemon. Each build used a separate Cargo target directory.

Build Time Cache hits Cache misses
First worktree 1m 16s 0 200 (176 Rust, 13 C/C++, 11 assembler)
Second worktree 1m 15s 24 (13 C/C++, 11 assembler) 176 Rust

The second build had a 12% cache hit rate across cacheable compilations and no
cache read, write, or configuration errors. All Rust compilations missed because
absolute worktree paths remained part of their compiler inputs. This is why the
change makes the cache location configurable but does not set
SCCACHE_BASEDIRS or promise universal Rust reuse across worktrees.

  • Unit tests added/updated (not applicable; configuration and documentation only)
  • E2E tests added/updated (not applicable)

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs updated (not applicable; developer tooling behavior is documented in CONTRIBUTING.md)

The source branch name was explicitly selected for this work and does not include an issue number.

Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
@copy-pr-bot

copy-pr-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@github-actions

Copy link
Copy Markdown

Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
@matthewgrossman
matthewgrossman marked this pull request as ready for review July 20, 2026 23:36
drew
drew previously approved these changes Jul 20, 2026
Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
@matthewgrossman
matthewgrossman added this pull request to the merge queue Jul 21, 2026
Merged via the queue into main with commit 8d9502d Jul 21, 2026
32 checks passed
@matthewgrossman
matthewgrossman deleted the mgrossman/shared-sccache branch July 21, 2026 04:47
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