From 0f7ea15ab41b35c9254cb91cc140752d83ca33e0 Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Wed, 18 Nov 2026 14:46:38 -0500 Subject: [PATCH 1/4] feat(rust): time every load phase and validation pass, and commit a 20x baseline The loader now records how long each phase (read, json parse, tree build, merge, super resolution, validation, reference resolution, freeze) and each validation pass took, in LoadResult.timings. load_bench prints a table per phase and per pass plus peak memory, and with --baseline the change against the committed baseline (baselines/load-20x.json, written by --write-baseline). The rust CI lane prints that table. Record only: no number ever fails a build. validate.rs is the ordered pass list the validation features register into; each pass is timed under its own name, so a slowdown names the feature that caused it. Baseline (20x fitness model, 7,140 nodes, median of 41, release, quiet-ish host): json parse 3.136 ms | tree build 8.068 | merge 0.502 | super resolution 0.138 validation 0.000 (no passes yet) | reference resolution 2.132 | freeze 0.057 peak memory 34,400 KiB (the bench's own sources included) --- scripts/ci-local.sh | 14 +- .../rust/metaobjects/baselines/load-20x.json | 17 ++ .../rust/metaobjects/examples/load_bench.rs | 153 ++++++++++++++- server/rust/metaobjects/src/lib.rs | 2 + server/rust/metaobjects/src/loader.rs | 47 ++++- server/rust/metaobjects/src/timing.rs | 174 ++++++++++++++++++ server/rust/metaobjects/src/validate.rs | 43 +++++ server/rust/metaobjects/tests/loader_edges.rs | 26 +++ 8 files changed, 464 insertions(+), 12 deletions(-) create mode 100644 server/rust/metaobjects/baselines/load-20x.json create mode 100644 server/rust/metaobjects/src/timing.rs create mode 100644 server/rust/metaobjects/src/validate.rs diff --git a/scripts/ci-local.sh b/scripts/ci-local.sh index 5fa6113bf3..704c00da15 100755 --- a/scripts/ci-local.sh +++ b/scripts/ci-local.sh @@ -72,7 +72,8 @@ # # rust → the Rust port (preview): cargo fmt # # --check, clippy -D warnings, and its # # tests, which run the registry and -# # metamodel corpora. No docker half. +# # metamodel corpora, then the load_bench +# # table (record only). No docker half. # # cube → the cube-model live check: a real Cube # # (cubejs/cube, pinned) over a private # # Postgres, both in docker (FR-044). Its @@ -826,7 +827,16 @@ gate_conf_rust() { ( cd server/rust \ && cargo fmt --all --check \ && cargo clippy --locked --all-targets -q -- -D warnings \ - && cargo test --locked -q -- --nocapture ) + && cargo test --locked -q -- --nocapture \ + && gate_rust_load_bench ) +} +# Load time per phase and per validation pass on the 20x fitness model, with the change +# against the committed baseline. Record only: it prints a table and never fails on a +# number, so a slowdown is read in the log and named by the feature that caused it. The +# baseline is regenerated by hand (`load_bench --write-baseline`) when a feature lands. +gate_rust_load_bench() { + cargo run --release --locked -q --example load_bench -- 20 15 \ + --baseline metaobjects/baselines/load-20x.json } gate_conf_kotlin() { ( cd server/java \ diff --git a/server/rust/metaobjects/baselines/load-20x.json b/server/rust/metaobjects/baselines/load-20x.json new file mode 100644 index 0000000000..bf52edac63 --- /dev/null +++ b/server/rust/metaobjects/baselines/load-20x.json @@ -0,0 +1,17 @@ +{ + "note": "Record only: a reference to read, never a threshold. Regenerate with load_bench --write-baseline.", + "model": "20 copies of the fitness model", + "nodes": 7140, + "iterations": 41, + "phases": { + "json parse": 3.136, + "tree build": 8.068, + "merge": 0.502, + "super resolution": 0.138, + "validation": 0.0, + "reference resolution": 2.132, + "freeze": 0.057 + }, + "passes": {}, + "peakRssKiB": 34400 +} diff --git a/server/rust/metaobjects/examples/load_bench.rs b/server/rust/metaobjects/examples/load_bench.rs index cf8f17fb59..11eda9932b 100644 --- a/server/rust/metaobjects/examples/load_bench.rs +++ b/server/rust/metaobjects/examples/load_bench.rs @@ -8,15 +8,25 @@ //! Run it in release mode: //! //! ```text -//! cargo run --release --example load_bench [-- ] +//! cargo run --release --example load_bench [-- +//! [--baseline ] [--write-baseline ]] //! ``` +//! +//! It prints one table of time per load phase and one of time per validation pass +//! (the median over the iterations), and the peak memory of the process. With +//! `--baseline` each row also shows the baseline's figure and the change; with +//! `--write-baseline` the run is saved in that file's format. A baseline is a record +//! to read: the comparison never fails the run. use std::time::{Duration, Instant}; +use serde_json::{Map, Value, json}; + use metaobjects::loader::Loader; use metaobjects::node::{NodeId, Tree}; use metaobjects::providers::default_registry; use metaobjects::serializer::canonical_serialize; +use metaobjects::timing::{LoadTimings, ms, render_table}; const FITNESS: &str = include_str!("../../../../fixtures/persistence-conformance/canonical/meta.fitness.json"); @@ -39,8 +49,76 @@ fn read_pass(tree: &Tree) -> usize { n } +/// The median of each named timing across the iterations, in first-seen order. +fn median_by_name(runs: &[Vec<(String, f64)>]) -> Vec<(String, f64)> { + let mut names: Vec = Vec::new(); + for run in runs { + for (n, _) in run { + if !names.contains(n) { + names.push(n.clone()); + } + } + } + names + .into_iter() + .map(|n| { + let mut v: Vec = runs + .iter() + .map(|r| r.iter().find(|(m, _)| *m == n).map_or(0.0, |(_, t)| *t)) + .collect(); + v.sort_by(f64::total_cmp); + let mid = v[v.len() / 2]; + (n, mid) + }) + .collect() +} + +fn rows(t: &[metaobjects::timing::Timing]) -> Vec<(String, f64)> { + t.iter() + .map(|x| (x.name.to_string(), ms(x.duration))) + .collect() +} + +/// The peak resident set of this process in KiB (`VmHWM`), where the OS reports it. +fn peak_rss_kib() -> Option { + let status = std::fs::read_to_string("/proc/self/status").ok()?; + let line = status.lines().find(|l| l.starts_with("VmHWM:"))?; + line.split_whitespace().nth(1)?.parse().ok() +} + +fn to_json_rows(rows: &[(String, f64)]) -> Value { + Value::Object( + rows.iter() + .map(|(n, t)| (n.clone(), json!((t * 1000.0).round() / 1000.0))) + .collect::>(), + ) +} + +fn from_json_rows(v: &Value) -> Vec<(String, f64)> { + v.as_object() + .map(|m| { + m.iter() + .filter_map(|(k, v)| Some((k.clone(), v.as_f64()?))) + .collect() + }) + .unwrap_or_default() +} + fn main() { - let mut args = std::env::args().skip(1); + let mut baseline_path = None; + let mut write_path = None; + let mut positional = Vec::new(); + let mut raw = std::env::args().skip(1); + while let Some(a) = raw.next() { + match a.as_str() { + "--baseline" => baseline_path = Some(raw.next().expect("--baseline takes a file")), + "--write-baseline" => { + write_path = Some(raw.next().expect("--write-baseline takes a file")); + } + _ => positional.push(a), + } + } + let mut args = positional.into_iter(); let copies: usize = args .next() .map_or(20, |a| a.parse().expect("copies is a number")); @@ -72,6 +150,8 @@ fn main() { let mut serializes = Vec::with_capacity(iterations); let mut cold_reads = Vec::with_capacity(iterations); let mut warm_reads = Vec::with_capacity(iterations); + let mut phase_runs = Vec::with_capacity(iterations); + let mut pass_runs = Vec::with_capacity(iterations); let mut nodes = 0; for _ in 0..iterations { let t = Instant::now(); @@ -83,6 +163,9 @@ fn main() { result.errors.first() ); nodes = result.tree.len(); + let timings: &LoadTimings = &result.timings; + phase_runs.push(rows(&timings.phases)); + pass_runs.push(rows(&timings.passes)); let t = Instant::now(); std::hint::black_box(read_pass(&result.tree)); cold_reads.push(t.elapsed()); @@ -103,6 +186,72 @@ fn main() { "load (parse, merge, extends, references), median of {iterations}: {:?}", median(loads) ); + let phases = median_by_name(&phase_runs); + let passes = median_by_name(&pass_runs); + let peak = peak_rss_kib(); + let baseline: Option = baseline_path.as_ref().map(|p| { + serde_json::from_str(&std::fs::read_to_string(p).expect("baseline file is readable")) + .expect("baseline file is JSON") + }); + println!(); + print!( + "{}", + render_table( + "load phase", + &phases, + baseline + .as_ref() + .map(|b| from_json_rows(&b["phases"])) + .as_deref() + ) + ); + println!(); + if passes.is_empty() { + println!("validation passes: none implemented yet"); + } else { + print!( + "{}", + render_table( + "validation pass", + &passes, + baseline + .as_ref() + .map(|b| from_json_rows(&b["passes"])) + .as_deref() + ) + ); + } + println!(); + match ( + peak, + baseline.as_ref().and_then(|b| b["peakRssKiB"].as_u64()), + ) { + (Some(now), Some(was)) => println!( + "peak memory: {} KiB (baseline {was} KiB, {:+.1}%)", + now, + (now as f64 - was as f64) / was as f64 * 100.0 + ), + (Some(now), None) => println!("peak memory: {now} KiB"), + (None, _) => println!("peak memory: not reported on this OS"), + } + if let Some(path) = write_path { + let doc = json!({ + "note": "Record only: a reference to read, never a threshold. Regenerate with load_bench --write-baseline.", + "model": format!("{copies} copies of the fitness model"), + "nodes": nodes, + "iterations": iterations, + "phases": to_json_rows(&phases), + "passes": to_json_rows(&passes), + "peakRssKiB": peak, + }); + std::fs::write( + &path, + format!("{}\n", serde_json::to_string_pretty(&doc).unwrap()), + ) + .expect("baseline file is writable"); + println!("baseline written to {path}"); + } + println!(); println!( "resolved reads of every node (children, attrs, is_array), first pass fills the cache, median of {iterations}: {:?}", median(cold_reads) diff --git a/server/rust/metaobjects/src/lib.rs b/server/rust/metaobjects/src/lib.rs index f73418baf8..d0ab293594 100644 --- a/server/rust/metaobjects/src/lib.rs +++ b/server/rust/metaobjects/src/lib.rs @@ -14,6 +14,8 @@ pub mod providers; pub mod registry; pub mod serializer; pub mod source; +pub mod timing; +pub mod validate; pub use errors::MetaError; pub use loader::{LoadResult, Loader}; diff --git a/server/rust/metaobjects/src/loader.rs b/server/rust/metaobjects/src/loader.rs index 596b718a8a..03bdd42186 100644 --- a/server/rust/metaobjects/src/loader.rs +++ b/server/rust/metaobjects/src/loader.rs @@ -21,6 +21,11 @@ use crate::node::{Node, NodeId, PACKAGE_SEP, Tree}; use crate::parser::{SUBTYPE_ROOT, TYPE_METADATA, TYPE_OBJECT, parse_document}; use crate::registry::TypeRegistry; use crate::source::ErrorSource; +use crate::timing::{ + LoadTimings, PHASE_FREEZE, PHASE_JSON, PHASE_MERGE, PHASE_READ, PHASE_REFS, PHASE_SUPERS, + PHASE_TREE, +}; +use crate::validate::{self, Ctx, Findings}; /// The extensions a directory load picks up. YAML is a later step of this port; /// a `.yaml` file is reported rather than silently skipped. @@ -53,6 +58,8 @@ pub struct LoadResult { pub root: NodeId, pub errors: Vec, pub warnings: Vec, + /// How long each phase and each validation pass took. + pub timings: LoadTimings, } /// Loads metadata against one registry. @@ -112,6 +119,8 @@ impl<'r> Loader<'r> { /// an `Err`; a file that cannot be read is an error in the result, and the /// other files still load. pub fn load_dir(&self, dir: &Path) -> std::io::Result { + let mut timings = LoadTimings::default(); + let read_start = std::time::Instant::now(); let files = metadata_files(dir, false)?; let mut sources = Vec::with_capacity(files.len()); let mut unreadable = Vec::new(); @@ -126,7 +135,8 @@ impl<'r> Loader<'r> { )), } } - let mut result = self.load_sources(&sources); + timings.add_phase(PHASE_READ, read_start.elapsed()); + let mut result = self.load_timed(&sources, timings); unreadable.append(&mut result.errors); result.errors = unreadable; Ok(result) @@ -134,6 +144,10 @@ impl<'r> Loader<'r> { /// Load `(id, text)` pairs, each one JSON document named `id` in errors. pub fn load_sources(&self, sources: &[(String, String)]) -> LoadResult { + self.load_timed(sources, LoadTimings::default()) + } + + fn load_timed(&self, sources: &[(String, String)], mut timings: LoadTimings) -> LoadResult { let mut tree = Tree::new(); let mut errors = Vec::new(); let mut roots = Vec::new(); @@ -155,14 +169,17 @@ impl<'r> Loader<'r> { )); continue; } - let doc: Value = match serde_json::from_str(text) { + let doc: Result = timings.phase(PHASE_JSON, || serde_json::from_str(text)); + let doc: Value = match doc { Ok(v) => v, Err(e) => { errors.push(MetaError::at(ERR_MALFORMED_JSON, e.to_string(), envelope)); continue; } }; - let parsed = parse_document(&doc, self.registry, &mut tree, id); + let parsed = timings.phase(PHASE_TREE, || { + parse_document(&doc, self.registry, &mut tree, id) + }); // An unknown type or subtype drops only that node, so the rest of the // document is kept; any other parse error drops the document, as the // TypeScript and Python loaders do. @@ -175,24 +192,38 @@ impl<'r> Loader<'r> { roots.push(root); } } + let mut warnings = Vec::new(); let root = if roots.is_empty() { tree.add(Node::new(TYPE_METADATA, SUBTYPE_ROOT, "")) } else { - let root = merge_roots(&mut tree, &roots, &mut errors); + let root = timings.phase(PHASE_MERGE, || merge_roots(&mut tree, &roots, &mut errors)); // Neither pass adds, removes or renames a top-level node, so one index serves both. let top = TopLevel::build(&tree, root); - resolve_supers(&mut tree, root, &top, &mut errors); - resolve_references(&mut tree, root, &top); + timings.phase(PHASE_SUPERS, || { + resolve_supers(&mut tree, root, &top, &mut errors); + }); + let mut findings = Findings::default(); + let ctx = Ctx { + tree: &tree, + root, + registry: self.registry, + strict: false, + }; + validate::run(&ctx, &mut findings, &mut timings); + errors.append(&mut findings.errors); + warnings.append(&mut findings.warnings); + timings.phase(PHASE_REFS, || resolve_references(&mut tree, root, &top)); root }; // The terminal phase: the tree is complete, so it becomes read-only and its // resolving reads memoize from here on (the other ports freeze at REGISTERED). - tree.freeze(); + timings.phase(PHASE_FREEZE, || tree.freeze()); LoadResult { tree, root, errors, - warnings: Vec::new(), + warnings, + timings, } } } diff --git a/server/rust/metaobjects/src/timing.rs b/server/rust/metaobjects/src/timing.rs new file mode 100644 index 0000000000..97da96e181 --- /dev/null +++ b/server/rust/metaobjects/src/timing.rs @@ -0,0 +1,174 @@ +//! Per-phase and per-validation-pass timing of one load. +//! +//! Every load records how long each phase and each validation pass took, so a +//! slowdown can be traced to the feature that caused it. The numbers are for +//! reading, never for failing a build: nothing in the crate asserts on them. +//! +//! The recorder is one `Instant` pair per phase and per pass, so the cost of keeping +//! it is far below the resolution of what it measures. + +use std::fmt::Write as _; +use std::time::{Duration, Instant}; + +/// A load phase, in the order the loader runs them. +pub const PHASE_READ: &str = "read files"; +pub const PHASE_JSON: &str = "json parse"; +pub const PHASE_TREE: &str = "tree build"; +pub const PHASE_MERGE: &str = "merge"; +pub const PHASE_SUPERS: &str = "super resolution"; +pub const PHASE_VALIDATE: &str = "validation"; +pub const PHASE_REFS: &str = "reference resolution"; +pub const PHASE_FREEZE: &str = "freeze"; + +/// One named measurement. +#[derive(Debug, Clone, PartialEq)] +pub struct Timing { + pub name: &'static str, + pub duration: Duration, +} + +/// The phases and validation passes of one load, each in the order it first ran. +/// A name recorded twice (one parse per file) accumulates into one entry. +#[derive(Debug, Clone, Default, PartialEq)] +pub struct LoadTimings { + pub phases: Vec, + pub passes: Vec, +} + +fn add(list: &mut Vec, name: &'static str, duration: Duration) { + match list.iter_mut().find(|t| t.name == name) { + Some(t) => t.duration += duration, + None => list.push(Timing { name, duration }), + } +} + +impl LoadTimings { + /// Add `duration` to the phase `name`. + pub fn add_phase(&mut self, name: &'static str, duration: Duration) { + add(&mut self.phases, name, duration); + } + + /// Add `duration` to the validation pass `name`. + pub fn add_pass(&mut self, name: &'static str, duration: Duration) { + add(&mut self.passes, name, duration); + } + + /// Run `f`, recording its time under the phase `name`. + pub fn phase(&mut self, name: &'static str, f: impl FnOnce() -> T) -> T { + let start = Instant::now(); + let out = f(); + self.add_phase(name, start.elapsed()); + out + } + + /// Run `f`, recording its time under the validation pass `name`. + pub fn pass(&mut self, name: &'static str, f: impl FnOnce() -> T) -> T { + let start = Instant::now(); + let out = f(); + self.add_pass(name, start.elapsed()); + out + } + + /// The time recorded for phase `name`, zero when it never ran. + pub fn phase_time(&self, name: &str) -> Duration { + self.phases + .iter() + .find(|t| t.name == name) + .map_or(Duration::ZERO, |t| t.duration) + } + + /// The sum of every phase. + pub fn total(&self) -> Duration { + self.phases.iter().map(|t| t.duration).sum() + } + + /// Fold another load's timings in, by name (the benchmark sums its iterations). + pub fn merge(&mut self, other: &LoadTimings) { + for t in &other.phases { + add(&mut self.phases, t.name, t.duration); + } + for t in &other.passes { + add(&mut self.passes, t.name, t.duration); + } + } +} + +/// Milliseconds with three decimals: the unit every table prints. +pub fn ms(d: Duration) -> f64 { + d.as_secs_f64() * 1000.0 +} + +/// A fixed-width table of `rows` (name, milliseconds), each against its baseline +/// milliseconds when `baseline` carries that name. A name with no baseline row prints +/// `new`; a baseline row nobody measured prints nothing (the pass was removed). +pub fn render_table( + title: &str, + rows: &[(String, f64)], + baseline: Option<&[(String, f64)]>, +) -> String { + let width = rows + .iter() + .map(|(n, _)| n.len()) + .max() + .unwrap_or(0) + .max(title.len()); + let mut out = String::new(); + match baseline { + Some(_) => writeln!( + out, + "{title:10} {:>10} {:>9}", + "ms", "baseline", "delta" + ), + None => writeln!(out, "{title:10}", "ms"), + } + .ok(); + for (name, now) in rows { + match baseline { + None => writeln!(out, "{name:10.3}"), + Some(base) => match base.iter().find(|(n, _)| n == name) { + Some((_, was)) => { + let delta = if *was > 0.0 { + format!("{:+.1}%", (now - was) / was * 100.0) + } else { + "n/a".to_string() + }; + writeln!(out, "{name:10.3} {was:>10.3} {delta:>9}") + } + None => writeln!( + out, + "{name:10.3} {:>10} {:>9}", + "-", "new" + ), + }, + } + .ok(); + } + out +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn a_name_recorded_twice_accumulates_in_first_seen_order() { + let mut t = LoadTimings::default(); + t.add_phase("a", Duration::from_millis(2)); + t.add_phase("b", Duration::from_millis(1)); + t.add_phase("a", Duration::from_millis(3)); + assert_eq!(t.phases.len(), 2); + assert_eq!(t.phases[0].name, "a"); + assert_eq!(t.phase_time("a"), Duration::from_millis(5)); + assert_eq!(t.total(), Duration::from_millis(6)); + assert_eq!(t.phase_time("missing"), Duration::ZERO); + } + + #[test] + fn the_table_prints_the_delta_against_the_baseline() { + let rows = vec![("merge".to_string(), 1.5), ("fresh".to_string(), 2.0)]; + let base = vec![("merge".to_string(), 1.0)]; + let table = render_table("phase", &rows, Some(&base)); + assert!(table.contains("+50.0%"), "{table}"); + assert!(table.contains("new"), "{table}"); + } +} diff --git a/server/rust/metaobjects/src/validate.rs b/server/rust/metaobjects/src/validate.rs new file mode 100644 index 0000000000..aaf8fda884 --- /dev/null +++ b/server/rust/metaobjects/src/validate.rs @@ -0,0 +1,43 @@ +//! The validation passes, run in the order the TypeScript reference runs them. +//! +//! Each pass is one named function over the merged, super-resolved tree. Order is +//! part of the contract: the corpus compares error envelopes position by position, so +//! a pass added here goes where the reference runs it. Every pass is timed under its +//! own name (see [`crate::timing`]), so adding one shows in the benchmark table. + +use crate::errors::MetaError; +use crate::node::{NodeId, Tree}; +use crate::registry::TypeRegistry; +use crate::timing::{LoadTimings, PHASE_VALIDATE}; + +/// What a pass reads. +pub struct Ctx<'a> { + pub tree: &'a Tree, + pub root: NodeId, + pub registry: &'a TypeRegistry, + /// Strict mode, as the loader option of that name. + pub strict: bool, +} + +/// What a pass writes. Errors and warnings are separate channels, as in every port. +#[derive(Debug, Default)] +pub struct Findings { + pub errors: Vec, + pub warnings: Vec, +} + +/// One validation pass. +pub type PassFn = fn(&Ctx<'_>, &mut Findings); + +/// Every pass, in the reference's order, each under the name the benchmark prints. +pub const PASSES: &[(&str, PassFn)] = &[]; + +/// Run every pass, timing each under its own name and all of them under the +/// `validation` phase. +pub fn run(ctx: &Ctx<'_>, findings: &mut Findings, timings: &mut LoadTimings) { + let start = std::time::Instant::now(); + for (name, pass) in PASSES { + timings.pass(name, || pass(ctx, findings)); + } + timings.add_phase(PHASE_VALIDATE, start.elapsed()); +} diff --git a/server/rust/metaobjects/tests/loader_edges.rs b/server/rust/metaobjects/tests/loader_edges.rs index 2f0bd50c78..21787306bc 100644 --- a/server/rust/metaobjects/tests/loader_edges.rs +++ b/server/rust/metaobjects/tests/loader_edges.rs @@ -147,3 +147,29 @@ fn a_symlink_cycle_is_walked_once() { std::fs::remove_dir_all(&dir).expect("clean up"); assert_eq!(found.expect("walk").len(), 1); } + +#[test] +fn a_load_records_the_time_of_every_phase() { + use metaobjects::timing::{ + PHASE_FREEZE, PHASE_JSON, PHASE_MERGE, PHASE_REFS, PHASE_SUPERS, PHASE_TREE, PHASE_VALIDATE, + }; + let r = load(&[( + "meta.a.json", + r#"{"metadata.root": {"package": "acme", "children": [ + {"object.entity": {"name": "A"}}]}}"#, + )]); + let names: Vec<&str> = r.timings.phases.iter().map(|t| t.name).collect(); + assert_eq!( + names, + [ + PHASE_JSON, + PHASE_TREE, + PHASE_MERGE, + PHASE_SUPERS, + PHASE_VALIDATE, + PHASE_REFS, + PHASE_FREEZE + ] + ); + assert!(r.timings.total() > std::time::Duration::ZERO); +} From d707838ac68f4f05e2cc39f7f2c20d4f51c63945 Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Wed, 18 Nov 2026 14:54:52 -0500 Subject: [PATCH 2/4] no-mistakes(review): apply reviewer inline fixes --- server/rust/metaobjects/src/loader.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/rust/metaobjects/src/loader.rs b/server/rust/metaobjects/src/loader.rs index 03bdd42186..265d5d2211 100644 --- a/server/rust/metaobjects/src/loader.rs +++ b/server/rust/metaobjects/src/loader.rs @@ -2,7 +2,8 @@ //! spell every reference canonically. //! //! Order of passes, as in every port: parse → merge → super resolution → -//! (validation, a later step of this port) → reference resolution. +//! validation (its passes are registered as the validation features land) → +//! reference resolution. //! //! Built for speed from the start: each file is read once and parsed straight into //! one arena, nothing is written to disk, and the passes walk the tree a fixed From 899c7c050570fabb7a0afcf7baedccf72100bd6d Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Wed, 18 Nov 2026 14:58:50 -0500 Subject: [PATCH 3/4] no-mistakes(review): drop cross-machine CI baseline; remove unused merge --- scripts/ci-local.sh | 15 +++++++++------ server/rust/metaobjects/src/timing.rs | 10 ---------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/scripts/ci-local.sh b/scripts/ci-local.sh index 704c00da15..61d80873cf 100755 --- a/scripts/ci-local.sh +++ b/scripts/ci-local.sh @@ -830,13 +830,16 @@ gate_conf_rust() { && cargo test --locked -q -- --nocapture \ && gate_rust_load_bench ) } -# Load time per phase and per validation pass on the 20x fitness model, with the change -# against the committed baseline. Record only: it prints a table and never fails on a -# number, so a slowdown is read in the log and named by the feature that caused it. The -# baseline is regenerated by hand (`load_bench --write-baseline`) when a feature lands. +# Load time per phase and per validation pass on the 20x fitness model. Record only: +# it prints a table and never fails on a number, so a slowdown is read in the log and +# named by the feature that caused it. No --baseline here: baselines/load-20x.json was +# recorded on one host, and a CI delta against it would measure the machine, not the +# change. Deltas are a same-machine workflow — record your own baseline before a +# feature lands and compare after it, from server/rust: +# cargo run --release --locked --example load_bench -- 20 15 --write-baseline +# cargo run --release --locked --example load_bench -- 20 15 --baseline gate_rust_load_bench() { - cargo run --release --locked -q --example load_bench -- 20 15 \ - --baseline metaobjects/baselines/load-20x.json + cargo run --release --locked -q --example load_bench -- 20 15 } gate_conf_kotlin() { ( cd server/java \ diff --git a/server/rust/metaobjects/src/timing.rs b/server/rust/metaobjects/src/timing.rs index 97da96e181..fa578882e2 100644 --- a/server/rust/metaobjects/src/timing.rs +++ b/server/rust/metaobjects/src/timing.rs @@ -81,16 +81,6 @@ impl LoadTimings { pub fn total(&self) -> Duration { self.phases.iter().map(|t| t.duration).sum() } - - /// Fold another load's timings in, by name (the benchmark sums its iterations). - pub fn merge(&mut self, other: &LoadTimings) { - for t in &other.phases { - add(&mut self.phases, t.name, t.duration); - } - for t in &other.passes { - add(&mut self.passes, t.name, t.duration); - } - } } /// Milliseconds with three decimals: the unit every table prints. From 1e9260528f497d23ae6cef4817f59f7b8bb158f7 Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Wed, 18 Nov 2026 15:11:13 -0500 Subject: [PATCH 4/4] no-mistakes(document): record Rust load-timing surface in changelog --- CHANGELOG.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc3b11affc..176966bb35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,9 +24,15 @@ here.** While the port is in preview, a new fixture that fails in Rust and is not on the ledger prints a warning and does not fail the lane; a fixture that passed and regresses still fails it, because the ledger records how many fixtures must pass. Nothing is published and there is no codegen - or `cargo meta` command yet. A `rust` lane runs `cargo fmt --check`, clippy and the tests in - `scripts/ci-local.sh --only rust`, `pr-ci` and `local-ci`, selected by changes under - `server/rust/`. + or `cargo meta` command yet. Every load records how long each phase and each validation pass + took (`LoadResult::timings`; the `validate` module's ordered pass list is empty on purpose + until those passes land), and `load_bench` prints the per-phase and per-pass medians, with + `--write-baseline` / `--baseline` to record and compare a run — a baseline is a record to + read, never a threshold, and the committed 20x baseline is a machine-local reference. A + `rust` lane runs `cargo fmt --check`, clippy, the tests and the `load_bench` table (record + only, printed without a baseline delta — a cross-machine delta measures the machine, not the + change) in `scripts/ci-local.sh --only rust`, `pr-ci` and `local-ci`, selected by changes + under `server/rust/`. ### Changed