pub struct CleanupConfig {
pub task_retention_duration: Duration,
pub enable_automatic_cleanup: bool,
pub max_retained_tasks: usize,
}Expand description
Configuration for completed-task retention.
The executor releases the state of finished tasks in whole blocks of 1,024
tasks as it registers new ones, so retained memory follows the spawn rate
without a background thread. A block is released once every task in it has
finished and either its newest completion is older than
task_retention_duration or more than max_retained_tasks finished tasks
are retained. One long-running task therefore keeps its own block resident.
A released task still reports as completed to wait_for_task and accepts
cancel_task as a no-op; only its status and statistics are gone, so
task_status and task_stats return None.
Fields§
§task_retention_duration: DurationHow long finished-task metadata stays observable.
§Default: 5 minutes
enable_automatic_cleanup: boolWhether the executor releases finished-task metadata at all.
When disabled every task’s metadata is retained for the executor’s lifetime and memory grows with the number of tasks spawned.
§Default: true
max_retained_tasks: usizeMost finished tasks retained regardless of age, rounded up to whole blocks of 1,024 tasks.
This is the hard bound on retained memory for a workload that finishes
tasks faster than task_retention_duration elapses.