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:
1 parent
c2b07734c6
commit
e3b56cb213
3 files changed
+45
-4
No files matched your search
@@ -34,10 +34,16 @@ pub struct Config {
|
||||
pub sccache: OsString,
|
||||
/// The SQLite file the history is saved in.
|
||||
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 {
|
||||
/// `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`.
|
||||
pub fn from_env() -> Result<Config, String> {
|
||||
let sccache = std::env::var_os("SCCACHE_DASH_SCCACHE").unwrap_or_else(|| "sccache".into());
|
||||
@@ -46,6 +52,7 @@ impl Config {
|
||||
Ok(Config {
|
||||
sccache,
|
||||
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.
|
||||
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 now - when < START_EVERY {
|
||||
return Err(self
|
||||
|
||||
@@ -91,6 +91,7 @@ esac
|
||||
Config {
|
||||
sccache: self.script.clone().into(),
|
||||
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]
|
||||
fn a_missing_sccache_server_is_started_once_then_read() {
|
||||
let fake = Fake::new();
|
||||
|
||||
Reference in new issue
Block a user