Skip to main content

compute_workspace_budget

Function compute_workspace_budget 

Source
pub(super) fn compute_workspace_budget(
    available_bytes: usize,
    n_workers: usize,
    model_rss_per_worker: usize,
    safety_factor: f64,
) -> (usize, usize, f64)
Expand description

Computes per-worker workspace budget and derived stats from memory inputs.

§Returns

(per_worker_workspace, worst_case_peak, utilization_pct) where:

  • per_worker_workspace: bytes available to one worker for a single session.run() call (passed as rss_ceiling to the probe).
  • worst_case_peak: total bytes consumed when all workers run simultaneously at budget ceiling (used for the 90% OOM warning).
  • utilization_pct: worst_case_peak / available_bytes × 100.

Extracted as a pure function so the budget logic is unit-testable independently of the async readiness probe machinery.