Skip to content

cache: expose manual on-demand iroh-blobs GC trigger (blocked on upstream) #520

Open

Description

@thiras

Summary

#518 wired periodic iroh-blobs GC into the runtime via Options { gc: Some(GcConfig { ... }) } and the add_protected callback hook (cache metrics: gc_runs_total, gc_bytes_reclaimed_total). One acceptance bullet from #518 was deferred:

Manual decdn admin cache gc admin RPC for on-demand reclamation.

There is no path through the public iroh-blobs API to trigger a sweep on demand without re-implementing gc_run_once ourselves — and we cannot, because the building blocks gc_run_once needs are also pub(crate).

Blocker

iroh-blobs 0.100 (and 0.101) publicly expose only GcConfig, ProtectCb, ProtectOutcome from iroh_blobs::store. The actual sweep functions and their building blocks are crate-private:

  • iroh_blobs::store::gc::{run_gc, gc_run_once} — module is mod gc; (private), only the three types above are re-exported.
  • iroh_blobs::api::blobs::Blobs::{delete, delete_with_opts, clear_protected} — pub(crate), reserved for the GC task.

Without one of these, an external crate can:

Suggested upstream patch

The minimal change is making gc_run_once pub and re-exporting it from iroh_blobs::store:

// iroh-blobs/src/store/mod.rs
pub use gc::{gc_run_once, GcConfig, ProtectCb, ProtectOutcome};

gc_run_once already takes &Store and &mut HashSet<Hash>, so the signature is operator-friendly. With it exposed:

  1. CacheEngine gains pub async fn run_gc(&self) -> CacheResult<GcReport> that calls iroh_blobs::store::gc_run_once.
  2. AdminRpc::cache_gc calls it from crates/node/src/admin.rs.
  3. decdn node gc exposes it on the CLI side, mirroring decdn node evict.

The pre/post snapshot mechanism #518 added stays useful — it can move to the new path and replace the lagged-delta approximation with a precise per-call reclaim count.

Cross-references

Acceptance

  • iroh-blobs upstream exposes gc_run_once (or equivalent one-shot trigger) publicly.
  • CacheEngine::run_gc() lands and returns a precise GcReport { blobs_deleted, bytes_reclaimed, duration }.
  • admin_v1_cacheGc JSON-RPC method exposed on the loopback admin surface (ADR 025).
  • decdn node gc [--json] CLI subcommand, output shape matches decdn node evict (key=value lines or --json).
  • Existing gc_runs_total / gc_bytes_reclaimed_total metrics continue to monotonically increase across both periodic and manual paths (no double-counting).

Activity

  1. added
    kind:feature
    status:blocked
    on May 10, 2026
  2. added
    rust
    on Jun 5, 2026
  3. self-assigned this
    on Jul 28, 2026
  4. added this to the v0.1 milestone on Jul 28, 2026
  5. thiras commented on Aug 1, 2026

    @thiras
    ContributorAuthor

    Upstream re-check (2026-08-01): the workspace now pins iroh-blobs 0.103 (body says 0.100/0.101). In 0.103.0 gc_run_once became pub async fn (store/gc.rs:179) — but mod gc is still private, store/mod.rs still re-exports only {GcConfig, ProtectCb, ProtectOutcome}, and Blobs::delete / delete_with_opts remain pub(crate) (api/blobs.rs:159,166). Upstream main is identical and v0.103.0 is the latest tag.

    One step closer (the function is public now), still blocked (nothing exports a path to call it). Our side is unchanged and self-consistent (crates/cache/src/engine.rs:838-846 still documents exactly this and points here).

  6. removed this from the v0.1 milestone on Aug 4, 2026
  7. yigitdot commented on Aug 14, 2026

    @yigitdot
    Contributor

    Concrete data point from #1678, plus the instrumentation to see it.

    Reclaim lag surfaced while removing max_blob_size_mb. With the blob-size cap gone, cache_size_mb becomes the only ceiling and the eviction driver becomes its sole enforcer. That made the gap this issue tracks load-bearing rather than cosmetic: release_for_eviction only drops the protecting tag, so bytes come back on the interval-driven GC sweep (gc_interval_sec, 300s default) while the driver ticks at eviction_tick_secs (1s). Between a high-water crossing and the next sweep, the budget is over-committed and nothing can reclaim it sooner.

    Re-confirmed still blocked upstream, against the pinned source rather than the doc comment:

    • gc_run_once is pub at iroh-blobs-0.103.0/src/store/gc.rs:179, but store/mod.rs:11 declares mod gc; private and mod.rs:20 re-exports only GcConfig/ProtectCb/ProtectOutcome.
    • Blobs::delete and Blobs::clear_protected are pub(crate); Store::connect/listen need the rpc feature, and decdn enables only fs-store.
    • cargo search iroh-blobs → 0.103.0 is the latest published version, so there is no upgrade that escapes this.

    The only externally reachable trigger remains Options::gc, whose interval is fixed at FsStore::load_with_opts.

    What #1678 landed instead — measurement, so the lag is visible while the fix stays blocked:

    • decdn_cache_pending_reclaim_bytes — bytes released but not yet reclaimed. This is the lag, directly. It was already tracked in DriverState.pending_reclaim but never exported. Healthy is a sawtooth draining each gc_interval_sec; stuck-high means reclaim is losing to admission.
    • decdn_cache_evicting — the hysteresis latch, so sustained pressure is distinguishable from a passing spike.
    • decdn_cache_fill_in_flight_bytes — inbound content committed but not yet written, via a new FillRegistry::total_in_flight_bytes().

    When upstream exposes the sweep, the driver can call it directly at the high-water crossing; pending_reclaim then collapses toward zero and the accounting it exists to support can be simplified. Until then these three metrics are how an operator sees the cost.

  8. moved this from Backlog to Blocked in deCDNon Aug 20, 2026
  9. thiras commented on Sep 28, 2026

    @thiras
    ContributorAuthor

    Upstream re-check (2026-09-28): still blocked. v0.103.0 is still the latest release, and upstream main has the same surface: a private mod gc;, only GcConfig/ProtectCb/ProtectOutcome re-exported, and Blobs::delete/delete_with_opts/clear_protected still pub(crate).

    n0-computer/iroh-blobs#235 asks for exactly this. The maintainers say they left out a manual run_gc() on purpose ("GC shouldn't be costly if it's run reasonably frequently") and asked for concrete use cases. I posted ours there: n0-computer/iroh-blobs#235 (comment). It covers the eviction driver's reclaim lag from #1678 (1s eviction tick vs. 300s GC sweep, measured by decdn_cache_pending_reclaim_bytes) and proposes either a public one-shot sweep that reports what it reclaimed or a "sweep soon" wake handle on the background GC task. It also offers a PR.

    Next step: see how upstream responds on #235 before starting any work here.

  10. added
    area:cache
    and removed on Oct 21, 2026
  11. thiras commented on Oct 29, 2026

    @thiras
    ContributorAuthor

    Upstream re-check (2026-10-29): still blocked, now against iroh-blobs v0.104.0 (released 2026-10-28). #2745 moves the workspace to 0.104.

    In the v0.104.0 tag:

    • src/store/mod.rs:11 is still a private mod gc;, and line 20 still re-exports only GcConfig, ProtectCb and ProtectOutcome.
    • gc_run_once (gc.rs:185) and run_gc (gc.rs:228) are pub, but no path outside the crate reaches them.
    • Blobs::delete_with_opts, delete and clear_protected (api/blobs.rs:159,166,545) are still pub(crate).
    • None of the 30 commits from v0.103.1 to v0.104.0 adds a manual sweep or a wake handle. Upstream main is the same.

    n0-computer/iroh-blobs#235 is still open, and our 2026-09-28 use-case comment there has no maintainer reply. No open upstream PR adds a manual sweep; the open GC PRs (#240, #248) fix races in the mark phase.

    One related fix in v0.104.0 does not affect us. iroh-blobs#317 stops GC from sweeping a hash-sequence root's children when the root is already live before the mark. That happens when a protect callback adds the root, or when the root has both a raw tag and a hash-sequence tag. Our gc_protect_callback adds nothing to the live set, and the cache and node crates create no hash-sequence tags.

    Our side still matches: the #520 pointers in crates/cache/src/engine.rs and crates/cache/src/metrics.rs describe the code correctly (#2745 updates the version they name).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:cachekind:featureprio:lowruststatus:blocked

Type

No type

Fields

Priority

None yet

Projects

  • Status
    Blocked

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions