Skip to main content

plan

Function plan 

Source
pub fn plan(
    request: &Request,
    delivery: &Delivery,
    route: Route,
) -> Result<Plan, RequestError>
Expand description

Validate a request and derive the least-retention plan for its delivery and route.

A summary reducer is legal when no content analysis is requested, the sole requested view is an unfiltered summary, the scan observes no control state, and the policy does not require the snapshot to participate. crate::open and live sessions still promise an index and therefore always plan full retention. Any future requirement the compact tier cannot prove falls closed to RetainedState::FullIndex.

Control observation is the caller’s decision, not this planner’s: a report’s rows carry the ignored share of every size they show (fdu-elnn), so a scan that reads .gitignore displays what it paid for, and one that turned it off shows no share rather than a zero. The summary reducer keeps no table to classify with, so an observing summary falls closed to the index. That trades the reducer’s small footprint for the ignored share in the default fdu --view summary; the performance ledger records what it costs.

The compact tier is not gated on the cache being unavailable, because for an unfiltered metadata summary the snapshot cannot save the work the scan is doing. Revalidating a loaded snapshot stats every entry anyway, so the reusable index and its write are additive cost with nothing to amortise them: measured on Linux/ext4 over 84,539 entries, the compact tier answered in 71 ms against 161 ms for a warm revalidating Auto run, and even a no-scan stale answer cost 81 ms because deserialisation is about as expensive per record as a warm walk. A snapshot earns its keep when it avoids expensive work — re-reading file bodies for content analysis, or a cold filesystem walk — not when it merely mirrors a walk that still has to happen.

Two deliveries still require the index, for reasons that are about intent rather than cost. Delivery::stale_ok must answer from the snapshot without touching the tree, so it has no scan to reduce. CachePolicy::On is an explicit request to leave a current snapshot, and honouring it means materialising the index that gets written — though with no cache path configured there is nothing to write, and the compact tier answers it like any other summary.

Persistence follows the same reasoning as the read. Under CachePolicy::Auto a one-shot metadata report writes nothing, because no later one-shot report reads what it would store: on a million-entry Linux tree the write was 0.26 s of a 1.51 s default run. Content analysis writes, because its sidecar spares re-reading unchanged files and is paired with the snapshot beside it; sessions, watches, and refreshes write, because they are the later reader.