Never start sccache unless asked; compact reasons panel

A server started from the dashboard has the dashboard's environment, not
the builds'. It came up with the 10 GB default beside a 250 GB cache and
sccache trimmed the cache. Starting is now opt-in
(SCCACHE_DASH_START_SCCACHE=1) and the README says why.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-28 18:32:20 -07:00
1 parent c2b07734c6
commit e3b56cb213
3 files changed
+45 -4

No files matched your search

+8 -2
View File
@@ -74,8 +74,14 @@ reading ever is a baseline and counts for nothing.
## Notes on sccache ## Notes on sccache
When no sccache server is running, sccache-dash starts one (`sccache --start-server`); if that sccache-dash never starts or stops sccache's server by itself. When none is running it shows
fails it shows "not running" with the error and tries again a minute later. "not running"; sccache starts its own server on your next build, with your build's settings.
To have sccache-dash start the server when none is running, set `SCCACHE_DASH_START_SCCACHE=1`
in its environment. Be careful with this: a server started that way gets sccache-dash's
environment, not your build's. If your cache size or folder is set only in your build's
environment, the server comes up with sccache's defaults, and sccache deletes cache entries
until the cache fits the 10 GB default.
While sccache-dash runs, sccache's server stays up: being asked for its stats every 10 seconds While sccache-dash runs, sccache's server stays up: being asked for its stats every 10 seconds
keeps it from shutting itself down after 10 idle minutes. keeps it from shutting itself down after 10 idle minutes.
+12 -2
View File
@@ -34,10 +34,16 @@ pub struct Config {
pub sccache: OsString, pub sccache: OsString,
/// The SQLite file the history is saved in. /// The SQLite file the history is saved in.
pub history: PathBuf, pub history: PathBuf,
/// Whether to start sccache's server when none is listening. Off unless asked for: a
/// server started from here has this program's environment, not the builds', so it can
/// come up with another cache size or folder, and sccache trims the cache to the size
/// it is started with.
pub start_sccache: bool,
} }
impl Config { impl Config {
/// `SCCACHE_DASH_SCCACHE` names the sccache command (`sccache` when unset); the history /// `SCCACHE_DASH_SCCACHE` names the sccache command (`sccache` when unset);
/// `SCCACHE_DASH_START_SCCACHE=1` lets it start sccache's server; the history
/// lives in `$XDG_DATA_HOME/sccache-dash/history.db`. /// lives in `$XDG_DATA_HOME/sccache-dash/history.db`.
pub fn from_env() -> Result<Config, String> { pub fn from_env() -> Result<Config, String> {
let sccache = std::env::var_os("SCCACHE_DASH_SCCACHE").unwrap_or_else(|| "sccache".into()); let sccache = std::env::var_os("SCCACHE_DASH_SCCACHE").unwrap_or_else(|| "sccache".into());
@@ -46,6 +52,7 @@ impl Config {
Ok(Config { Ok(Config {
sccache, sccache,
history: dir.join("sccache-dash").join("history.db"), history: dir.join("sccache-dash").join("history.db"),
start_sccache: std::env::var_os("SCCACHE_DASH_START_SCCACHE").is_some_and(|v| v == "1"),
}) })
} }
} }
@@ -299,9 +306,12 @@ impl Task {
} }
} }
/// Starts sccache's server when none is listening, at most once a minute. `Err` says why /// Starts sccache's server when none is listening and that was asked for, at most once a minute. `Err` says why
/// there is none, including when an earlier attempt is still being waited out. /// there is none, including when an earlier attempt is still being waited out.
fn start_server(&mut self, app: &App, now: i64) -> Result<(), String> { fn start_server(&mut self, app: &App, now: i64) -> Result<(), String> {
if !app.cfg.start_sccache {
return Err("no sccache server is running; your next build starts it".to_owned());
}
if let Some(when) = self.started_at { if let Some(when) = self.started_at {
if now - when < START_EVERY { if now - when < START_EVERY {
return Err(self return Err(self
+25
View File
@@ -91,6 +91,7 @@ esac
Config { Config {
sccache: self.script.clone().into(), sccache: self.script.clone().into(),
history: self.history.clone(), history: self.history.clone(),
start_sccache: true,
} }
} }
} }
@@ -444,6 +445,30 @@ fn old_rows_are_deleted_at_startup() {
); );
} }
#[test]
fn a_missing_sccache_server_is_left_alone_unless_starting_was_asked_for() {
let fake = Fake::new();
fake.down();
let app = App::with_probe(
Config {
start_sccache: false,
..fake.config()
},
fake.probe(),
);
let mut task = Task::memory();
task.poll(&app, NOW);
task.poll(&app, NOW + 120);
let calls = fake.calls();
assert!(!calls.iter().any(|c| c == "--start-server"), "{calls:?}");
assert!(app
.lock()
.error
.as_deref()
.is_some_and(|e| e.contains("your next build starts it")));
}
#[test] #[test]
fn a_missing_sccache_server_is_started_once_then_read() { fn a_missing_sccache_server_is_started_once_then_read() {
let fake = Fake::new(); let fake = Fake::new();