feat(daemon): run sync passes on a worker pool

The loop thread schedules and sync.workers threads (default 4) run passes,
so a slow or hanging fetch no longer holds up every other repo. A repo never
has two passes at once; passes go only to idle workers, so pause and backoff
behave as before. Visibility and merged-PR caches are shared without holding
locks across forge requests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Opus 5.5 committed 2026-11-17 16:02:41 +01:00
1 parent 6e5bee1a95
commit f16438fa02
7 files changed
+317 -127

No files matched your search

+14
View File
@@ -171,6 +171,10 @@ pub struct Sync {
/// (`prune::default_protected`) and the default branch. See [`Sync::protected_branches`].
#[serde(default)]
pub prune_protected: Vec<String>,
/// How many repos the daemon syncs at the same time (1 to 32). A repo never has two
/// passes at once.
#[serde(default = "default_workers")]
pub workers: usize,
}
impl Sync {
@@ -194,6 +198,7 @@ impl Default for Sync {
prune_merged: true,
prune_disposable: default_disposable(),
prune_protected: Vec::new(),
workers: default_workers(),
}
}
}
@@ -207,6 +212,9 @@ pub struct ConfigRepo {
fn yes() -> bool {
true
}
fn default_workers() -> usize {
4
}
fn default_debounce() -> u64 {
2000
}
@@ -347,6 +355,12 @@ impl Config {
));
}
}
if !(1..=32).contains(&self.sync.workers) {
return bad(format!(
"sync.workers = {} must be between 1 and 32",
self.sync.workers
));
}
if let Some(d) = self
.sync
.prune_disposable
+4 -1
View File
@@ -47,7 +47,10 @@ fn temp_index_path() -> PathBuf {
.duration_since(UNIX_EPOCH)
.map(|d| d.as_nanos())
.unwrap_or(0);
std::env::temp_dir().join(format!("grove-index-{}-{nanos}", std::process::id()))
// A counter too: daemon workers snapshot several repos at once.
static SEQ: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
let n = SEQ.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
std::env::temp_dir().join(format!("grove-index-{}-{nanos}-{n}", std::process::id()))
}
/// Tree of everything in the worktree (tracked changes and untracked files, not ignored ones),