Repository navigation
Description
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 gcadmin 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 ismod 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:
- Configure a periodic sweep via
Options.gc. - Hook in via
ProtectCb(cache: wire iroh-blobs GC into runtime — partial-import bytes (hash-mismatch, mid-stream cap breach) currently leak disk indefinitely #518's metrics path uses this). - NOT trigger a one-shot sweep on operator demand.
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:
CacheEnginegainspub async fn run_gc(&self) -> CacheResult<GcReport>that callsiroh_blobs::store::gc_run_once.AdminRpc::cache_gccalls it fromcrates/node/src/admin.rs.decdn node gcexposes it on the CLI side, mirroringdecdn 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
- Periodic GC wiring lands as part of cache: wire iroh-blobs GC into runtime — partial-import bytes (hash-mismatch, mid-stream cap breach) currently leak disk indefinitely #518 PR.
- Code references:
crates/cache/src/engine.rsgc_protect_callbackandopen_full's docstring (the "follow-up issue tracks …" note). - Threat model unchanged from cache: wire iroh-blobs GC into runtime — partial-import bytes (hash-mismatch, mid-stream cap breach) currently leak disk indefinitely #518 — periodic sweep already mitigates the disk-leak amplification window; this issue is about operator ergonomics, not a security gap.
Acceptance
- iroh-blobs upstream exposes
gc_run_once(or equivalent one-shot trigger) publicly. -
CacheEngine::run_gc()lands and returns a preciseGcReport { blobs_deleted, bytes_reclaimed, duration }. -
admin_v1_cacheGcJSON-RPC method exposed on the loopback admin surface (ADR 025). -
decdn node gc [--json]CLI subcommand, output shape matchesdecdn node evict(key=value lines or--json). - Existing
gc_runs_total/gc_bytes_reclaimed_totalmetrics continue to monotonically increase across both periodic and manual paths (no double-counting).
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Projects
- StatusShow more project fieldsBlocked
Activity
fixup(cache): correct gc cycle-break docs + orphan ratio framing (#518)
feat(cache): wire iroh-blobs GC into runtime (#518) (#521)
thiras commentedon Aug 1, 2026
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_oncebecamepub async fn(store/gc.rs:179) — butmod gcis still private,store/mod.rsstill re-exports only{GcConfig, ProtectCb, ProtectOutcome}, andBlobs::delete/delete_with_optsremainpub(crate)(api/blobs.rs:159,166). Upstreammainis 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-846still documents exactly this and points here).yigitdot commentedon Aug 14, 2026
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_mbbecomes 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_evictiononly drops the protecting tag, so bytes come back on the interval-driven GC sweep (gc_interval_sec, 300s default) while the driver ticks ateviction_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_onceispubatiroh-blobs-0.103.0/src/store/gc.rs:179, butstore/mod.rs:11declaresmod gc;private andmod.rs:20re-exports onlyGcConfig/ProtectCb/ProtectOutcome.Blobs::deleteandBlobs::clear_protectedarepub(crate);Store::connect/listenneed therpcfeature, and decdn enables onlyfs-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, whoseintervalis fixed atFsStore::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 inDriverState.pending_reclaimbut never exported. Healthy is a sawtooth draining eachgc_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 newFillRegistry::total_in_flight_bytes().When upstream exposes the sweep, the driver can call it directly at the high-water crossing;
pending_reclaimthen 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.thiras commentedon Sep 28, 2026
Upstream re-check (2026-09-28): still blocked. v0.103.0 is still the latest release, and upstream
mainhas the same surface: a privatemod gc;, onlyGcConfig/ProtectCb/ProtectOutcomere-exported, andBlobs::delete/delete_with_opts/clear_protectedstillpub(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 bydecdn_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.
thiras commentedon Oct 29, 2026
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:11is still a privatemod gc;, and line 20 still re-exports onlyGcConfig,ProtectCbandProtectOutcome.gc_run_once(gc.rs:185) andrun_gc(gc.rs:228) arepub, but no path outside the crate reaches them.Blobs::delete_with_opts,deleteandclear_protected(api/blobs.rs:159,166,545) are stillpub(crate).mainis 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_callbackadds nothing to the live set, and the cache and node crates create no hash-sequence tags.Our side still matches: the
#520pointers incrates/cache/src/engine.rsandcrates/cache/src/metrics.rsdescribe the code correctly (#2745 updates the version they name).