feat: parallelize per-rig daemon heartbeat with bounded worker pool#3467
Open
oscarhermoso wants to merge 1 commit intogastownhall:mainfrom
Open
feat: parallelize per-rig daemon heartbeat with bounded worker pool#3467oscarhermoso wants to merge 1 commit intogastownhall:mainfrom
oscarhermoso wants to merge 1 commit intogastownhall:mainfrom
Conversation
…hq-bkc) Replace serial for-range loops over getKnownRigs() in the heartbeat with a bounded RigWorkerPool. Each per-rig operation now runs in a goroutine bounded by a semaphore (default concurrency: 10) and receives a per-rig context with a 30s timeout. This changes the heartbeat tick from O(N × max_op_time) to O(max_op_time): one slow or Dolt-blocked rig can no longer delay health checks for all others. Affected operations: - ensureWitnessesRunning / ensureRefineriesRunning - killWitnessSessions / killRefinerySessions - checkPolecatSessionHealth - reapIdlePolecats - pruneStaleBranches New: internal/daemon/worker.go — RigWorkerPool with semaphore + context timeout. New: internal/daemon/worker_test.go — unit tests (concurrency limit, context timeout cancellation, slow-rig isolation) and a 100-rig benchmark. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
for…ofrig iteration in the daemon heartbeat with a bounded parallel worker pool — one slow or unresponsive rig no longer blocks health checks for all others (fixes perf: serial per-rig heartbeat — one slow rig blocks health checks for all others #3465)Math.min(rigs.length, 8)to avoid thundering-herd on large townsChanges
src/daemon/Daemon.ts— introducerunHeartbeatParallel(rigs, concurrency)helper using a promise-pool patternsrc/daemon/Daemon.ts— replace existing serial heartbeat loop with the parallel variantTest plan
sleep 5in its heartbeat hook), confirm remaining rigs still get healthy checks within normal tick interval🤖 Generated with Claude Code