Skip to main content

Module bounded

Module bounded 

Source
Expand description

The bound every long-lived table in this crate shares (RFC 09 §5.1 O6).

An explorer that runs for hours accumulates: per-key statistics, key projections, watch state. Every one of those tables needs the same three things — a ceiling, an eviction that amortises, and a count of what the ceiling cost — and two of them (StatsTable and FactsCache) had shipped a byte-identical copy of the mechanism: same evict fraction, same batch scan, same len - target batch, differing only in the recency type.

So the mechanism lives here, once, and the policy stays with each holder: BoundedLru::admit returns how many entries it dropped, and the caller adds that to its own ledger. “Evicted under the bound”, “retired because nothing watches it any more” and “never projected in the first place” are different facts, and one counter over several of them is exactly what O6 forbids.

Recency is the caller’s too: StatsTable orders by an injected last_seen: Instant, FactsCache by a monotone observation counter, and BoundedLru::admit takes whichever as a projection out of the value.

Constants§

DEFAULT_MAX_KEYS
Default key bound. Large enough that no ordinary fleet reaches it — the reference application’s whole telemetry fan is a few thousand keys — and small enough that a runaway key family cannot exhaust memory.