Skip to content

Commit 8d9502d

Browse files
perf(build): share sccache across worktrees (#2379)
* perf(build): share sccache across worktrees Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * fix(build): make sccache directory overridable Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> * fix(build): support pinned mise version Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> --------- Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
1 parent f169084 commit 8d9502d

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

‎CONTRIBUTING.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,28 @@ openshell --help
195195
openshell sandbox create -- codex
196196
```
197197

198+
### Rust build cache
199+
200+
Mise preserves an existing `SCCACHE_DIR` so each environment can choose where
201+
to store compiler cache entries. When `SCCACHE_DIR` is unset, OpenShell uses
202+
the worktree-local `.cache/sccache` directory. To make cache entries available
203+
to multiple worktrees on a workstation, set the variable to a user-level
204+
directory before activating mise. For example:
205+
206+
```shell
207+
export SCCACHE_DIR="$HOME/.cache/openshell/sccache"
208+
```
209+
210+
CI can select a different directory or configure a remote sccache backend
211+
without changing the workstation setting. Cargo output remains in each
212+
worktree's `target/` directory.
213+
214+
OpenShell does not set `SCCACHE_BASEDIRS`. Sccache loads base directories when
215+
its machine-local daemon starts, but the correct workspace root differs for
216+
each worktree. Cache reuse therefore depends on the compiler inputs: outputs
217+
that embed absolute paths, including Rust dependencies in some builds, can
218+
still miss across worktrees.
219+
198220
## Main Tasks
199221

200222
These are the primary `mise` tasks for day-to-day development:

‎mise.toml‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,10 @@ _.file = [".env"]
5353
KUBECONFIG = "{{config_root}}/kubeconfig"
5454
UV_CACHE_DIR = "{{config_root}}/.cache/uv"
5555

56-
# Enable sccache for faster Rust builds.
57-
# Local builds use a disk cache (SCCACHE_DIR); CI sets SCCACHE_MEMCACHED_ENDPOINT
58-
# via repository variables to use a shared memcached backend instead.
56+
# Enable sccache for faster Rust builds. Preserve an SCCACHE_DIR selected by the
57+
# caller so workstations and CI can configure their cache locations separately.
5958
RUSTC_WRAPPER = "sccache"
60-
SCCACHE_DIR = "{{config_root}}/.cache/sccache"
59+
SCCACHE_DIR = "{{ get_env(name='SCCACHE_DIR', default=config_root ~ '/.cache/sccache') }}"
6160

6261
# Shared build constants (overridable via environment).
6362
# DOCKER_BUILDKIT enables BuildKit for Docker; ignored by podman.

0 commit comments

Comments
 (0)