114 lines
4.5 KiB
Rust
114 lines
4.5 KiB
Rust
//! Bounded, opt-in macOS qualification workload. See --help.
|
|
#[path = "../tests/support/qualification.rs"]
|
|
mod qualification;
|
|
use prometeu_vm::resource_diagnostics::ResourceSnapshot;
|
|
use qualification::Workload;
|
|
use std::time::{Duration, Instant};
|
|
|
|
fn report(name: &str, frames: u64, hash: u64, s: &ResourceSnapshot) {
|
|
println!(
|
|
"checkpoint name={name} frames={frames} digest={hash:016x} cycles={} live={} free={} retired={} strings={} depth={} peak_depth={} used={:?} peaks={:?} limits={:?} reservation_refusals={:?} gc={} reclaimed={} gc_p50_upper_ns={} gc_p95_upper_ns={} gc_p99_upper_ns={} gc_max_ns={} mark_max_ns={} sweep_max_ns={} reconcile_max_ns={}",
|
|
s.cycles,
|
|
s.live_objects,
|
|
s.free_handles,
|
|
s.retired_handles,
|
|
s.tracked_strings,
|
|
s.call_depth,
|
|
s.peak_call_depth,
|
|
s.budget.used,
|
|
s.budget.peaks,
|
|
s.budget.limits,
|
|
s.budget.refusals,
|
|
s.gc.collections,
|
|
s.gc.reclaimed,
|
|
s.gc.total.percentile_upper_ns(50),
|
|
s.gc.total.percentile_upper_ns(95),
|
|
s.gc.total.percentile_upper_ns(99),
|
|
s.gc.total.max_ns,
|
|
s.gc.mark.max_ns,
|
|
s.gc.sweep.max_ns,
|
|
s.gc.string_reconciliation.max_ns
|
|
);
|
|
}
|
|
|
|
fn main() {
|
|
let args: Vec<_> = std::env::args().collect();
|
|
if args.len() != 3 || !matches!(args[1].as_str(), "--frames" | "--seconds") {
|
|
eprintln!(
|
|
"usage: resource_qualification --frames N | --seconds N\nRuns all three stationary families with lockstep replay; --seconds counts active batches only. Seed=73. Checkpoints every 10000 frames, fixed-size memory. Does not certify desktop or other hosts."
|
|
);
|
|
std::process::exit(2);
|
|
}
|
|
let amount: u64 = args[2].parse().expect("positive integer duration/frame count");
|
|
assert!(amount > 0);
|
|
let timed = args[1] == "--seconds";
|
|
println!(
|
|
"start os={} arch={} debug={} seed=73 mode={} amount={} pid={}",
|
|
std::env::consts::OS,
|
|
std::env::consts::ARCH,
|
|
cfg!(debug_assertions),
|
|
args[1],
|
|
amount,
|
|
std::process::id()
|
|
);
|
|
let mut workloads: Vec<_> =
|
|
qualification::NAMES.iter().map(|&name| Workload::new(name)).collect();
|
|
let mut replays: Vec<_> =
|
|
qualification::NAMES.iter().map(|&name| Workload::new(name)).collect();
|
|
let started = Instant::now();
|
|
let mut active = Duration::ZERO;
|
|
let mut excluded = Duration::ZERO;
|
|
while if timed { active.as_secs() < amount } else { workloads[0].frames < amount } {
|
|
let batch_started = Instant::now();
|
|
for (w, replay) in workloads.iter_mut().zip(&mut replays) {
|
|
let batch = if timed { 64 } else { 64.min(amount - w.frames) };
|
|
for _ in 0..batch {
|
|
w.frame();
|
|
replay.frame();
|
|
assert_eq!(w.digest, replay.digest, "{} replay at {}", w.name, w.frames);
|
|
if w.frames % 10_000 == 0 {
|
|
w.check_stationary();
|
|
replay.check_stationary();
|
|
assert_eq!(
|
|
w.vm.resource_snapshot().budget,
|
|
replay.vm.resource_snapshot().budget
|
|
);
|
|
report(w.name, w.frames, w.digest, &w.vm.resource_snapshot());
|
|
}
|
|
}
|
|
}
|
|
let elapsed = batch_started.elapsed();
|
|
// Conservatively exclude any long interval, including sleep/descheduling.
|
|
// This can extend the run; it never credits suspended time as active work.
|
|
if elapsed <= Duration::from_secs(2) {
|
|
active += elapsed;
|
|
} else {
|
|
excluded += elapsed;
|
|
}
|
|
}
|
|
println!(
|
|
"load_complete active_seconds={:.3} wall_seconds={:.3} excluded_seconds={:.3}",
|
|
active.as_secs_f64(),
|
|
started.elapsed().as_secs_f64(),
|
|
excluded.as_secs_f64()
|
|
);
|
|
for (w, replay) in workloads.into_iter().zip(replays) {
|
|
let name = w.name;
|
|
let frames = w.frames;
|
|
let expected = (w.digest, w.vm.resource_snapshot().cycles);
|
|
report(name, frames, w.digest, &w.vm.resource_snapshot());
|
|
w.finish();
|
|
assert_eq!(
|
|
(replay.digest, replay.vm.resource_snapshot().cycles),
|
|
expected,
|
|
"{name} replay"
|
|
);
|
|
replay.finish();
|
|
println!(
|
|
"replay_pass name={name} frames={frames} digest={:016x} cycles={} disposed_usage=zero",
|
|
expected.0, expected.1
|
|
);
|
|
}
|
|
println!("qualification_pass scope=vm_workloads_only");
|
|
}
|