Repository navigation
refactor(node): collapse the five periodic GC/log runners into one spawn_periodic helper (#1250) - #1272
Conversation
…awn_periodic helper (#1250) The five periodic runners (run_dispatch_gc, run_region_accounting_log, run_record_store_gc, run_dht_rate_limit_gc, run_probe_rate_limit_gc) were byte-identical modulo their tick body: an interval ticker with a burned first tick and a `loop { select! { biased; stop | tick } }`. Collapse them into a single `spawn_periodic(&mut tasks, name, interval, tick)` helper that mints the oneshot internally, spawns onto the JoinSet, and returns the stop sender. The tick bodies become closures at the call sites in run(); a shared log_keyspace_gc helper absorbs the DHT/probe two-layer log arms. Behavior is preserved verbatim: biased stop-before-tick ordering, first-tick burn, MissedTickBehavior::Delay, per-runner intervals and log levels/fields, the region opt-out, and the shutdown fire order. The load-bearing doc comments (the record-store per-publisher-quota rationale and the DHT-GC panic contract + gauge-alerting note) are relocated to their call sites. The only observable change is the shutdown debug line, now one message with a `task=<name>` field instead of five distinct strings. The five duplicated shutdown-promptness tests collapse into spawn_periodic_exits_promptly_on_shutdown (which also newly pins the burned first tick), plus spawn_periodic_fires_the_tick_body pinning the positive path. Net -276 lines. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
Warning Review limit reached
Next review available in: 33 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (1)
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
There was a problem hiding this comment.
Pull request overview
This PR refactors the node runtime’s periodic maintenance/logging tasks by collapsing five nearly identical “interval + burned first tick + biased stop-before-tick select” runners into a single spawn_periodic helper. This reduces duplication in crates/node/src/runtime/mod.rs while preserving the shutdown promptness contract and existing tick behavior, and it consolidates tests to cover both the shutdown path and the positive “tick body actually runs” path.
Changes:
- Introduced
spawn_periodicto encapsulate the shared periodic-task loop (burn first tick,MissedTickBehavior::Delay,biasedstop-before-tick select) and return a stop sender. - Replaced the five prior periodic runner functions with call-site closures in
run(), including a small sharedlog_keyspace_gchelper for DHT/probe rate-limiter sweep logs. - Consolidated duplicated shutdown-promptness tests into
spawn_periodic_exits_promptly_on_shutdownand addedspawn_periodic_fires_the_tick_bodyto assert the tick arm executes.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage reportTotal: 81.49% (was 81.52%, ▼ 0.03%) — 48593/59628 lines
History
|
Summary
Closes #1250. The five periodic runners in
crates/node/src/runtime/mod.rs—run_dispatch_gc,run_region_accounting_log,run_record_store_gc,run_dht_rate_limit_gc,run_probe_rate_limit_gc— were byte-identical modulo their tick body: anintervalticker with a burned first tick and aloop { select! { biased; stop | tick } }. This collapses them into one helper:which mints the oneshot internally, spawns onto the
JoinSet, and returns the stop sender. The tick bodies become closures at the call sites inrun(); a sharedlog_keyspace_gchelper absorbs the DHT/probe two-layer log arms.Net −276 lines (173 insertions, 449 deletions).
Behavior preserved verbatim
biased; stop-before-tickselect ordering (prompt shutdown)MissedTickBehavior::Delayregion_accounting_interval_sec == 0disables + logs info)stop_txbinding names)The load-bearing doc comments — the record-store per-publisher-quota rationale and the DHT-GC panic contract + gauge-alerting note — are relocated to their call sites rather than dropped.
One observable change (call out for log-scrapers)
The shutdown-received debug line is now a single message with a
task=<name>field (task=dispatch_gc,task=record_store_gc, …) instead of five distinct strings. Debug-level only; no metric/series/log-level change.Tests
The five duplicated shutdown-promptness tests collapse into
spawn_periodic_exits_promptly_on_shutdown(which also newly pins the burned first tick), plus a newspawn_periodic_fires_the_tick_bodypinning the positive path — closing a pre-existing gap where a broken tick arm would leave all five GC tasks silently dead with no failing test.Verification
cargo fmt -- --check,cargo clippy -p decdn-node --all-targets,cargo build— all cleancargo nextest run -p decdn-node— 835 passed, 0 failedOut of scope
The watcher backoff/cycle recorders (#1266), the WatcherHandle ownership inversion (#1236), and the broader teardown registry — all deferred by #1250 itself.
🤖 Generated with Claude Code