Repository navigation
feat(rust): time every load phase and validation pass, with a bench table and 20x baseline - #602
Merged
Merged
Conversation
…0x 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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR 1 of the Rust parity stack. This PR is the measurement step only: the validation pass list is empty on purpose, and the passes, the conformance-ledger shrink and a raised
minPassingland in the next stacked PRs, all before 1.3.0. Gate runs for this PR: 1 (with two review fix rounds inside it).What Changed
timingmodule and avalidatemodule to the Rust loader: every load now records how long each phase (read, JSON parse, tree build, merge, super resolution, validation, reference resolution, freeze) and each validation pass took inLoadResult::timings. Thevalidatemodule runs between super resolution and reference resolution as in the other ports; its orderedPASSESlist is intentionally empty until the validation passes land in the stacked parity PRs (loader runs withstrict: falsefor now).load_benchexample to print median per-phase and per-validation-pass tables plus peak RSS, with--baseline <file>/--write-baseline <file>for same-machine comparison — a baseline is a record to read, never a threshold, and no comparison ever fails a run. A 20x-model baseline is committed atserver/rust/metaobjects/baselines/load-20x.jsonas a machine-local reference.scripts/ci-local.sh --only rust) now prints theload_benchtiming table, record-only and deliberately without a baseline delta (a cross-machine delta measures the machine, not the change); CHANGELOG updated to describe the timing surface.Validation
Risk Assessment
✅ Low: The change is measurement-only (timing recording, a benchmark table, a record-only baseline) with no behavior gates; the prior round's findings were fixed exactly as decided (merge removed, CI delta dropped) and the intent now explicitly authorizes every previously-questioned element (empty PASSES, strict=false, untouched ledger), leaving no substantiated defect.
Testing
Drove the three real surfaces of this measurement increment against the live product: (1) the CI lane's bench command prints the full 7-phase timing table with a validation row of 0.000 ms, 'validation passes: none implemented yet', and peak memory, with no baseline/delta columns — the record-only, no-cross-machine-delta shape the intent mandates; (2) the machine-local baseline workflow round-trips: --write-baseline emits a well-formed record and --baseline renders ms/baseline/delta columns with correct n/a handling for the zero-valued validation phase and a peak-memory comparison; (3) adversarially, a baseline with halved values and a removed phase yields +100–140% deltas, a '- new' row for the missing phase, +34152% on peak memory, and still exit 0 — the comparison never fails a run; (4) the focused loader integration test confirms every load records all seven phases in order through the public Loader API. No source files were modified, so the already-passing configured baseline run stands as broad regression; scratch files were deleted and the worktree is clean.
Evidence: CI lane bench table (record-only, no deltas)
Evidence: Same-machine baseline compare with delta columns
Evidence: Adversarial baseline run (+100% deltas, '- new' row, exit 0)
Evidence: Written baseline file format (--write-baseline output)
Evidence: Focused loader timing test result
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 4 issues found → auto-fixed ✅
server/rust/metaobjects/src/validate.rs:32- Intent conformance: the authoritative intent requires 'Bring the Rust loader to parity with the other ports' before the 1.3.0 release, and notes Rust 'skips validation the other ports run'. This change ships the validation scaffold with PASSES = &[] (validate.rs:32) and hardcodes Ctx.strict = false (loader.rs:210), leaves the conformance ledger untouched (tests/conformance-expected-failures.json still minPassing 256, unchanged by the diff), so after this change the Rust loader still runs zero validation passes and its speed remains partly unearned — exactly what the intent flags. The commit message frames this as the measurement increment ('validate.rs is the ordered pass list the validation features register into') and the intent says performance is recorded 'as features land', so it plausibly is step one of the parity line (branch fm/mo-rust-parity-validation) rather than its completion — but whether this PR is an acceptable partial increment of the REQUIRED parity goal, with the passes to follow before 1.3.0, is a scope decision only the author can confirm.server/rust/metaobjects/src/timing.rs:90- LoadTimings::merge (timing.rs:89-96) has no caller anywhere in the workspace (grep over server/rust confirms; the bench uses median_by_name in examples/load_bench.rs:53 instead) and its doc comment is factually wrong: it claims 'the benchmark sums its iterations', but the benchmark computes per-name medians and never calls merge. Remove the method (it is new in this change, so removal breaks nothing) or fix the comment to name a real future caller. Sibling: phase_time (timing.rs:73) is exercised only by timing.rs's own unit tests — acceptable for a public reader helper, noted here only so the fixer sees the full dead/unused surface.scripts/ci-local.sh:835- gate_rust_load_bench prints the CI run's per-phase deltas against baselines/load-20x.json, which was recorded on the maintainer's host (commit message: 'release, quiet-ish host', median of 41). The committed baseline (scripts/ci-local.sh:832-837) therefore makes the CI table's 'baseline' and 'delta' columns measure machine and environment differences, not feature-caused slowdowns — the captain's requirement 'if something slows down we can see which feature caused it' is only satisfiable when baseline and run share a machine. Record-only means nothing fails, but the CI delta column is noise that could mask or fake a regression signal. The remedy is an author decision (e.g. the CI lane prints the table without --baseline and deltas stay a machine-local workflow, or baselines are recorded per environment), so it needs authorization rather than an auto-fix.server/rust/metaobjects/src/loader.rs:5- Applied inline: the module doc still said validation was '(validation, a later step of this port)', but this change wires validate::run into the pipeline; reworded to 'validation (its passes are registered as the validation features land)'. Comment-only, no behavior change.🔧 Fix applied.
2 issues (1 warning, 1 info) still open:
server/rust/metaobjects/src/validate.rs:32- Intent conformance: the authoritative intent requires 'Bring the Rust loader to parity with the other ports' before the 1.3.0 release, and notes Rust 'skips validation the other ports run'. This change ships the validation scaffold with PASSES = &[] (validate.rs:32) and hardcodes Ctx.strict = false (loader.rs:210), leaves the conformance ledger untouched (tests/conformance-expected-failures.json still minPassing 256, unchanged by the diff), so after this change the Rust loader still runs zero validation passes and its speed remains partly unearned — exactly what the intent flags. The commit message frames this as the measurement increment ('validate.rs is the ordered pass list the validation features register into') and the intent says performance is recorded 'as features land', so it plausibly is step one of the parity line (branch fm/mo-rust-parity-validation) rather than its completion — but whether this PR is an acceptable partial increment of the REQUIRED parity goal, with the passes to follow before 1.3.0, is a scope decision only the author can confirm.server/rust/metaobjects/src/loader.rs:5- Applied inline: the module doc still said validation was '(validation, a later step of this port)', but this change wires validate::run into the pipeline; reworded to 'validation (its passes are registered as the validation features land)'. Comment-only, no behavior change.✅ No issues found.
✅ **Test** - passed
✅ No issues found.
scripts/ci-local.sh --affected --strict-toolchainsscripts/ci-local.sh --affected --strict-toolchains (configured baseline test command; already ran and passed at target commit 899c7c050)cargo run --release --locked -q --example load_bench -- 20 15 (exact gate_rust_load_bench command, from server/rust)cargo run --release --locked -q --example load_bench -- 20 15 --write-baseline $DEV_SCRATCH/mo-bench/scratch-baseline.jsoncargo run --release --locked -q --example load_bench -- 20 15 --baseline $DEV_SCRATCH/mo-bench/scratch-baseline.jsoncargo run --release --locked -q --example load_bench -- 20 15 --baseline <adversarial baseline: halved values, one phase removed> (exit 0)cargo test --locked -q --test loader_edges a_load_records✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.