mirror of
https://github.com/Dasemu/Grove.git
synced 2026-11-26 15:26:09 +00:00
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:
1 parent
6e5bee1a95
commit
f16438fa02
7 files changed
+317
-127
No files matched your search
+10
-2
@@ -17,8 +17,16 @@ is `grove_core::sync::sync_repo`, the same code the CLI runs. The daemon only de
|
||||
cannot starve snapshots.
|
||||
- **Periodic pass**: every `fetch_interval_s` all repos get a full pass (fetch, receive, apply
|
||||
snapshots, materialize/archive). Also what catches missed events.
|
||||
- **One worker thread**: passes never overlap. Events that arrive during a pass queue another pass;
|
||||
it finds nothing to do and ends the chain.
|
||||
- **Worker pool**: the loop thread only schedules; `sync.workers` threads (default 4, 1 to 32) run
|
||||
the passes, so a slow or hanging fetch of one repo no longer holds up the others. A repo never
|
||||
has two passes at once: one that becomes due while its pass runs is dispatched when it ends.
|
||||
Events that arrive during a pass queue another pass; it finds nothing to do and ends the chain.
|
||||
Passes are handed out only to idle workers, so the rest stay due: pause stops them, and whether
|
||||
a pass runs offline (backoff) is decided when it starts. A `sync` request for a repo whose pass
|
||||
is running is not undone by that pass failing. A panicking pass is logged and counts as a
|
||||
failure. Rediscovery does not drop or flag (stalled) a repo while its pass runs.
|
||||
The visibility and merged-PR caches are shared and never locked across a forge request.
|
||||
Shutdown and pause let running passes finish. `workers = 1` is the old sequential behaviour.
|
||||
- **Failures** (network, auth, git errors) back off exponentially per repo: 10 s, 20 s, ... capped at
|
||||
5 min, and are logged as `error`. `sync` over IPC clears the backoff. While backing off, changes
|
||||
are still snapshotted locally (an offline pass); only the network is retried after the backoff.
|
||||
|
||||
Reference in new issue
Block a user