Skip to content

refactor(node): collapse the five periodic GC/log runners into one spawn_periodic helper #1250

Closed

Description

@thiras

Problem

crates/node/src/runtime/mod.rs:167-418 holds five near-identical periodic runners — run_dispatch_gc, run_region_accounting_log, run_record_store_gc, run_dht_rate_limit_gc, run_probe_rate_limit_gc — each repeating the same tokio::time::interval + select! { biased; stop | tick } shape (~250 lines), plus five matching oneshot::channel::<()> stop channels minted and fired individually in run().

Proposed fix

One spawn_periodic(name, interval, tick_fn)-style helper returning a stop handle, plus five closures that delegate to the existing domain sweeps (gc_per_source, gc_per_ip, RecordStore::gc, the region-accounting log). Fold the per-runner oneshot minting/firing into the helper/handle.

Constraints to preserve verbatim:

  • the biased; stop-before-tick select ordering — the *_exits_promptly_on_shutdown tests (runtime/mod.rs:3570-3752) pin prompt-shutdown behavior, and the inline comments at mod.rs:261-264 / 327-334 warn against restructuring the loop body (a uniform wrapper is fine; splitting the body is not);
  • per-runner tick intervals and log levels.

~150-200 prod lines saved. Adjacent (not in scope here): the broader shutdown/teardown registry idea should wait for #1236 (WatcherHandle ownership inversion) — this issue is only the periodic-runner shape.

Risk

Low — behavior-preserving wrapper; the shutdown-promptness tests catch regressions.

Activity

  1. added
    rust
    prio:low
    on Jul 17, 2026
  2. self-assigned this
    on Jul 17, 2026
  3. assigned and unassigned on Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

prio:lowrust

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions