From b4ecc3e79963ebb1306f46d78cc397a46d34d0a5 Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Mon, 20 Jul 2026 15:40:51 -0700 Subject: [PATCH 1/3] perf(build): share sccache across worktrees Signed-off-by: Matthew Grossman --- CONTRIBUTING.md | 15 +++++++++++++++ mise.toml | 6 +++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e20d618d20..2fe9cc7894 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -195,6 +195,21 @@ openshell --help openshell sandbox create -- codex ``` +### Rust build cache + +Mise configures sccache to use `$XDG_CACHE_HOME/openshell/sccache`. When +`XDG_CACHE_HOME` is unset, mise uses the platform cache directory, such as +`$HOME/.cache` on Linux or `$HOME/Library/Caches` on macOS. All OpenShell +worktrees share this compiler cache, while Cargo output remains in each +worktree's `target/` directory. Existing worktree-local `.cache/sccache` +directories are not migrated automatically and can be removed manually when +they are no longer needed. + +OpenShell does not set `SCCACHE_BASEDIRS`. Sccache loads base directories when +its machine-local daemon starts, but the correct workspace root differs for +each worktree. Consequently, dependencies can be reused across worktrees while +absolute paths can still prevent hits for workspace-local crates. + ## Main Tasks These are the primary `mise` tasks for day-to-day development: diff --git a/mise.toml b/mise.toml index fc5ba340aa..8c134a6471 100644 --- a/mise.toml +++ b/mise.toml @@ -54,10 +54,10 @@ KUBECONFIG = "{{config_root}}/kubeconfig" UV_CACHE_DIR = "{{config_root}}/.cache/uv" # Enable sccache for faster Rust builds. -# Local builds use a disk cache (SCCACHE_DIR); CI sets SCCACHE_MEMCACHED_ENDPOINT -# via repository variables to use a shared memcached backend instead. +# Local builds share an OpenShell-specific user cache across worktrees; CI sets +# SCCACHE_MEMCACHED_ENDPOINT via repository variables to use memcached instead. RUSTC_WRAPPER = "sccache" -SCCACHE_DIR = "{{config_root}}/.cache/sccache" +SCCACHE_DIR = "{{xdg_cache_home}}/openshell/sccache" # Shared build constants (overridable via environment). # DOCKER_BUILDKIT enables BuildKit for Docker; ignored by podman. From 36c743d7141175acf638f5d0ef8127bcfa71871f Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Mon, 20 Jul 2026 16:28:20 -0700 Subject: [PATCH 2/3] fix(build): make sccache directory overridable Signed-off-by: Matthew Grossman --- CONTRIBUTING.md | 25 ++++++++++++++++--------- mise.toml | 7 +++---- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2fe9cc7894..ad20267ca6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -197,18 +197,25 @@ openshell sandbox create -- codex ### Rust build cache -Mise configures sccache to use `$XDG_CACHE_HOME/openshell/sccache`. When -`XDG_CACHE_HOME` is unset, mise uses the platform cache directory, such as -`$HOME/.cache` on Linux or `$HOME/Library/Caches` on macOS. All OpenShell -worktrees share this compiler cache, while Cargo output remains in each -worktree's `target/` directory. Existing worktree-local `.cache/sccache` -directories are not migrated automatically and can be removed manually when -they are no longer needed. +Mise preserves an existing `SCCACHE_DIR` so each environment can choose where +to store compiler cache entries. When `SCCACHE_DIR` is unset, OpenShell uses +the worktree-local `.cache/sccache` directory. To make cache entries available +to multiple worktrees on a workstation, set the variable to a user-level +directory before activating mise. For example: + +```shell +export SCCACHE_DIR="$HOME/.cache/openshell/sccache" +``` + +CI can select a different directory or configure a remote sccache backend +without changing the workstation setting. Cargo output remains in each +worktree's `target/` directory. OpenShell does not set `SCCACHE_BASEDIRS`. Sccache loads base directories when its machine-local daemon starts, but the correct workspace root differs for -each worktree. Consequently, dependencies can be reused across worktrees while -absolute paths can still prevent hits for workspace-local crates. +each worktree. Cache reuse therefore depends on the compiler inputs: outputs +that embed absolute paths, including Rust dependencies in some builds, can +still miss across worktrees. ## Main Tasks diff --git a/mise.toml b/mise.toml index 8c134a6471..62bfc4232a 100644 --- a/mise.toml +++ b/mise.toml @@ -53,11 +53,10 @@ _.file = [".env"] KUBECONFIG = "{{config_root}}/kubeconfig" UV_CACHE_DIR = "{{config_root}}/.cache/uv" -# Enable sccache for faster Rust builds. -# Local builds share an OpenShell-specific user cache across worktrees; CI sets -# SCCACHE_MEMCACHED_ENDPOINT via repository variables to use memcached instead. +# Enable sccache for faster Rust builds. Preserve an SCCACHE_DIR selected by the +# caller so workstations and CI can configure their cache locations separately. RUSTC_WRAPPER = "sccache" -SCCACHE_DIR = "{{xdg_cache_home}}/openshell/sccache" +SCCACHE_DIR = { default = "{{config_root}}/.cache/sccache" } # Shared build constants (overridable via environment). # DOCKER_BUILDKIT enables BuildKit for Docker; ignored by podman. From 81b7843047c3de9d0464f44be8550ec5da798999 Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Mon, 20 Jul 2026 16:48:30 -0700 Subject: [PATCH 3/3] fix(build): support pinned mise version Signed-off-by: Matthew Grossman --- mise.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mise.toml b/mise.toml index 62bfc4232a..a5d9682108 100644 --- a/mise.toml +++ b/mise.toml @@ -56,7 +56,7 @@ UV_CACHE_DIR = "{{config_root}}/.cache/uv" # Enable sccache for faster Rust builds. Preserve an SCCACHE_DIR selected by the # caller so workstations and CI can configure their cache locations separately. RUSTC_WRAPPER = "sccache" -SCCACHE_DIR = { default = "{{config_root}}/.cache/sccache" } +SCCACHE_DIR = "{{ get_env(name='SCCACHE_DIR', default=config_root ~ '/.cache/sccache') }}" # Shared build constants (overridable via environment). # DOCKER_BUILDKIT enables BuildKit for Docker; ignored by podman.