Conversation
grao1991
approved these changes
Feb 27, 2026
zekun000
approved these changes
Feb 27, 2026
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Replace the 1ms sleep-poll loop in `PrunerWorker` with a `sync_channel(1)`-based blocking wait. **Before:** Each pruner worker thread (state_merkle, ledger, state_kv) woke up every 1ms to check `is_pruning_pending()`, causing ~1000 context switches/sec per thread even when fully idle. **After:** The worker blocks on `recv()` when there's no pending work, and is woken only when: - `set_target_db_version` is called with a new target (`try_send(())`) - The `PrunerWorker` is dropped (sender dropped → `recv()` returns `Err`) This also eliminates the `PrunerWorkerInner` struct — the channel naturally separates the producer (sender on `PrunerWorker`) from the consumer (receiver moved into the worker thread). Error backoff is bumped from 1ms to 100ms. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Contributor
✅ Forge suite
|
Contributor
✅ Forge suite
|
Contributor
✅ Forge suite
|
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.
Replace the 1ms sleep-poll loop in
PrunerWorkerwith async_channel(1)-based blocking wait.Before: Each pruner worker thread (state_merkle, ledger, state_kv) woke up
every 1ms to check
is_pruning_pending(), causing ~1000 context switches/secper thread even when fully idle.
After: The worker blocks on
recv()when there's no pending work, and iswoken only when:
set_target_db_versionis called with a new target (try_send(()))PrunerWorkeris dropped (sender dropped →recv()returnsErr)This also eliminates the
PrunerWorkerInnerstruct — the channel naturallyseparates the producer (sender on
PrunerWorker) from the consumer (receivermoved into the worker thread). Error backoff is bumped from 1ms to 100ms.
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com
Note
Medium Risk
Changes the pruner worker’s concurrency model from tight sleep-polling to channel-based blocking wakeups, which can affect shutdown/wakeup behavior and risk hangs if signaling is missed. Scope is limited to
PrunerWorker, but it runs continuously in production so regressions would be noisy.Overview
Replaces
PrunerWorker’s 1ms sleep/poll loop with async_channel(1)wake mechanism so idle pruner threads block onrecv()and only run when signaled.set_target_db_version()nowtry_send(())s to wake the worker after advancing the target version, andDropsignals shutdown by dropping the sender (worker exits when the channel disconnects). The oldPrunerWorkerInner+AtomicBoolstop flag is removed, and pruning error backoff is increased to 100ms.Written by Cursor Bugbot for commit e4a6b8e. This will update automatically on new commits. Configure here.