Skip to content

server: scope SCCACHE_BASEDIRS to compiler requests - #2814

Draft
tcashel wants to merge 11 commits into
mozilla:mainfrom
tcashel:codex/request-scoped-basedirs
Draft

server: scope SCCACHE_BASEDIRS to compiler requests#2814
tcashel wants to merge 11 commits into
mozilla:mainfrom
tcashel:codex/request-scoped-basedirs

Conversation

@tcashel

@tcashel tcashel commented Aug 18, 2026

Copy link
Copy Markdown

Problem

I often have several coding agents build the same Rust project from separate Git
worktrees. Each build can identify its own checkout root, but the sccache daemon
currently captures SCCACHE_BASEDIRS when it starts. Supporting another
worktree therefore requires restarting the daemon or adding every checkout to
one global list.

This draft depends on #2813 and contains one commit on top of it. Until #2813
merges, GitHub includes both commits in this PR; view the follow-up-only
diff
.
I'll rebase this branch onto main after #2813 merges.

Change

Each compiler invocation can now override the file-configured basedirs. If
SCCACHE_BASEDIRS is absent, the invocation uses the configured fallback. An
empty value disables that fallback, while a relative value fails only that
invocation. Each request gets an isolated storage view, so concurrent builds
cannot affect one another. The same rules apply with SCCACHE_CLIENT_SIDE=1.

For example, these builds can use one running daemon:

cd /work/project
SCCACHE_BASEDIRS="$PWD" cargo build

cd /tmp/project-worktree
SCCACHE_BASEDIRS="$PWD" cargo build

Only the config file defines the daemon fallback, and statistics continue to
report only that value. This change does not discover Git worktrees, expand
wildcard roots, or add a wire-protocol field.

Validation

On Apple silicon, the required formatting, clippy, and locked test suites passed.
Focused Cargo tests cover daemon reuse, both client modes, override precedence,
configured statistics, and concurrent requests.

I also ran the final branch on Ubuntu x86_64. The full locked suite and all
single-backend builds passed. NVCC 12.4 ran both CUDA system-test modes without
skipping. In a two-root canary, request-scoped basedirs added a cross-root
CUDA hit while one daemon stayed running; the device-code and PTX stages still
missed.

The repository benchmark suite also completed. In one local run,
cache_key_generation had a 31.87 µs median, compared with 31.41 µs in the
PR #2813 run.

Fixes #2595.

I used OpenAI Codex (gpt-5.6-sol, ultra reasoning) during implementation,
testing, benchmarking, and review. I'll review the full diff and CI results
myself before marking the PR ready.

@codecov-commenter

codecov-commenter commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.34513% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.10%. Comparing base (8ab3926) to head (645971d).

Files with missing lines Patch % Lines
tests/sccache_cargo.rs 95.81% 9 Missing ⚠️
src/server.rs 80.76% 5 Missing ⚠️
src/cache/basedirs.rs 96.93% 3 Missing ⚠️
src/compiler/rust.rs 99.17% 2 Missing ⚠️
src/util.rs 98.40% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2814      +/-   ##
==========================================
+ Coverage   73.71%   74.10%   +0.38%     
==========================================
  Files          72       73       +1     
  Lines       37932    37684     -248     
==========================================
- Hits        27963    27927      -36     
+ Misses       9969     9757     -212     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tcashel
tcashel force-pushed the codex/request-scoped-basedirs branch from 102b45f to bd21c42 Compare August 22, 2026 02:22
@tcashel
tcashel force-pushed the codex/request-scoped-basedirs branch from bd21c42 to 019a7c1 Compare August 22, 2026 02:51
Comment thread benches/sccache_bench.rs Outdated
bencher.bench(|| black_box(strip_basedirs(black_box(&output), black_box(&basedirs))));
}

#[divan::bench(args = [0, 1, 8, 32])]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add the benchmark in a different pr

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.

SCCACHE_BASEDIRS support for Worktree workflow

3 participants