Skip to main content

simulate

Function simulate 

Source
pub fn simulate(
    config: &Config,
    memory_max: Option<u64>,
    cpu_budget: Option<u64>,
    jobs: &[Ran],
    policy: Policy,
    slots: &BTreeMap<String, u32>,
) -> Replay
Expand description

Replays jobs through policy: each arrives when it was queued and runs as long as it ran, in a profile with slots (by name; the config’s where absent) under the slice’s memory_max. Jobs start as soon as the policy admits them, oldest first, a job that does not fit letting a later one past, as scheduler::plan does. Measured admission predicts from the runs finished before it decides, as the daemon would, and holds each running job at its peak for its whole run, which the daemon does not see. A job with copies waiting or running beside it is predicted as one with Copies::Several. Each moment, the running jobs are predicted again, the first running copy of a job going by its own runs, as the daemon does each tick. Unlike the daemon, the replay knows a job from its start: it never sees a runner whose job is not known yet, and the order jobs started stands for the daemon’s slot order.

With a cpu_budget in millicores, a job also starts only when the CPU the running jobs reserve and its own fit it: by caps, each its profile’s cpus; measured, each its predicted average (Predictor::predict_cpu), at most the budget. The replay holds each job’s run time whatever the CPU it shares: it shows what admission holds back, not how much a busy CPU slows the jobs.