-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathenvelope.rs
More file actions
72 lines (66 loc) · 2.69 KB
/
Copy pathenvelope.rs
File metadata and controls
72 lines (66 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//! JSON output envelope for `benchmarks/results/*.json`.
//!
//! The shape is locked in 9.1 (Q8 — workload version + host fingerprint
//! together let same-version, same-host runs be diffed mechanically).
//! The aggregator binary (`src/bin/aggregate.rs`) walks
//! `target/criterion/**/new/estimates.json` after `cargo bench` and
//! emits one [`ResultsEnvelope`] per `make bench` invocation.
//!
//! Schema rationale:
//! - `host` carries enough to know "is this run comparable to that
//! one?" — CPU model, RAM, OS family, kernel rev. The plan's "macOS
//! vs Linux skew" risk is addressed by including `os_kind` so the
//! comparison script can refuse cross-OS diffs.
//! - `commit` (full SHA + dirty bit) lets us recover what was tested.
//! - `samples` is the per-(workload, driver) row, carrying every
//! number criterion produced. `compare.py` (lands in 9.6) reads
//! this directly.
use serde::{Deserialize, Serialize};
use crate::BenchSample;
/// Top-level results envelope. One file = one `make bench` run.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ResultsEnvelope {
/// Schema version. Bump when the envelope shape changes; allows
/// `compare.py` to refuse to diff incompatible files.
pub schema_version: u32,
/// Run timestamp in RFC 3339 (UTC). Captured at run start.
pub run_started_at: String,
/// Run duration, seconds wall-clock. Captured by the aggregator.
pub run_duration_secs: f64,
/// Host fingerprint (CPU / RAM / OS).
pub host: HostInfo,
/// Repo state at run time.
pub commit: CommitInfo,
/// One row per (workload-version, driver) pair.
pub samples: Vec<BenchSample>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HostInfo {
/// CPU model string. On macOS read from `sysctl machdep.cpu.brand_string`;
/// on Linux the first `model name` line in `/proc/cpuinfo`.
pub cpu: String,
/// Logical CPU count.
pub cpus: u32,
/// Total RAM in MiB.
pub ram_mib: u64,
/// `linux`, `macos`, `windows`, …
pub os_kind: String,
/// Kernel / OS version string (`uname -r`).
pub os_release: String,
/// CPU arch (`aarch64`, `x86_64`, …).
pub arch: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CommitInfo {
/// Full git SHA at run time. `"unknown"` if the run was outside a
/// git checkout.
pub sha: String,
/// Branch name at run time.
pub branch: String,
/// Working tree dirty? (uncommitted changes present)
pub dirty: bool,
}
/// Schema version. Bump whenever any field in [`ResultsEnvelope`] or
/// [`BenchSample`] changes shape; `compare.py` reads this and refuses
/// cross-version diffs.
pub const SCHEMA_VERSION: u32 = 1;