pub struct RetentionPolicy {
pub max_age: Duration,
pub max_completed_tasks: usize,
}Expand description
How long, and how many, completed tasks the registry keeps observable.
Retention is block-granular: a block of 1,024 tasks is released as one unit
once every task in it has completed and released its lifecycle token,
and either the block’s newest completion is older than max_age or more
than max_completed_tasks worth of blocks are resident. The cap holds
regardless of age, and it counts resident blocks, so a block pinned by a
running task and the block being filled count toward it.
A single long-running task keeps its own block resident (about 73 KiB)
however many later tasks complete, and no other. The sweep visits resident
blocks in a queue, eight per created block, so a settled block waits at
most one lap of that queue. With k the larger of the cap in blocks and the
pinned blocks plus the one being filled, the resident count stays at most
M + ceil(M / 8) for the least M with M >= k + ceil(M / 8), about 9/7
of k, however many blocks are created.
After release, TaskRegistry::is_completed stays true and a cancel
request still reports “already completed”; only per-task metadata and
statistics are gone.
Fields§
§max_age: DurationCompleted-task metadata older than this may be released.
max_completed_tasks: usizeMost completed tasks kept regardless of age, rounded up to whole blocks.
Implementations§
Source§impl RetentionPolicy
impl RetentionPolicy
Sourcepub fn from_cleanup(config: &CleanupConfig) -> Option<Self>
pub fn from_cleanup(config: &CleanupConfig) -> Option<Self>
The policy an executor derives from its cleanup configuration, or
None when automatic cleanup is disabled.