Skip to content

feat(rust): time every load phase and validation pass, with a bench table and 20x baseline - #602

Merged
dmealing merged 4 commits into
mainfrom
fm/mo-rust-parity-validation
Nov 18, 2026
Merged

dmealing merged 4 commits into
mainfrom
fm/mo-rust-parity-validation

Conversation

@dmealing

@dmealing dmealing commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

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 minPassing land 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

  • Added a timing module and a validate module 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 in LoadResult::timings. The validate module runs between super resolution and reference resolution as in the other ports; its ordered PASSES list is intentionally empty until the validation passes land in the stacked parity PRs (loader runs with strict: false for now).
  • Extended the load_bench example 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 at server/rust/metaobjects/baselines/load-20x.json as a machine-local reference.
  • The Rust CI lane (scripts/ci-local.sh --only rust) now prints the load_bench timing 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.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
CI lane prints the per-phase timing table record-only: cargo load_bench 20 15 shows all 7 phases, validation 0.000, 'validation passes: none implemented yet', peak memory, and no baseline/delta column… ✅ pass live local gate evidence (ci-lane-bench-table.txt)
Machine-local baseline workflow round-trips: --write-baseline saves a well-formed record and a follow-up --baseline run renders ms/baseline/delta columns with n/a for the zero validation phase and a p… ✅ pass live local gate evidence (baseline-compare-same-machine.txt) and written-baseline-format.json
Adversarial: the comparison never fails a run — a baseline with halved values and one removed phase produces +100–140% deltas, a '- new' row for the missing phase, +34152% peak-memory delta, and exit… ✅ pass live local gate evidence (adversarial-baseline-run.txt)
Loader-level guarantee: a load through the public Loader API records every phase in order (json parse, tree build, merge, super resolution, validation, reference resolution, freeze) ✅ pass live local gate evidence (loader-timing-test.txt)
Evidence: CI lane bench table (record-only, no deltas)
model: 20 copies of the fitness model, 714 KiB of JSON, 7140 nodes
registry compose: 1.67212ms
load (parse, merge, extends, references), median of 15: 15.056993ms

load phase                    ms
json parse                 3.139
tree build                 8.130
merge                      0.483
super resolution           0.122
validation                 0.000
reference resolution       1.972
freeze                     0.057

validation passes: none implemented yet

peak memory: 34304 KiB

resolved reads of every node (children, attrs, is_array), first pass fills the cache, median of 15: 2.13655ms
resolved reads of every node, from the cache, median of 15: 38.393µs
canonical serialize, median of 15: 9.862807ms
Evidence: Same-machine baseline compare with delta columns
model: 20 copies of the fitness model, 714 KiB of JSON, 7140 nodes
registry compose: 1.165019ms
load (parse, merge, extends, references), median of 15: 16.688125ms

load phase                    ms    baseline      delta
json parse                 3.273       3.317      -1.3%
tree build                 8.911       8.675      +2.7%
merge                      0.658       0.556     +18.4%
super resolution           0.172       0.151     +13.6%
validation                 0.000       0.000        n/a
reference resolution       2.814       2.451     +14.8%
freeze                     0.060       0.059      +2.4%

validation passes: none implemented yet

peak memory: 34284 KiB (baseline 34160 KiB, +0.4%)

resolved reads of every node (children, attrs, is_array), first pass fills the cache, median of 15: 3.51312ms
resolved reads of every node, from the cache, median of 15: 64.873µs
canonical serialize, median of 15: 17.592429ms
Evidence: Adversarial baseline run (+100% deltas, '- new' row, exit 0)
model: 20 copies of the fitness model, 714 KiB of JSON, 7140 nodes
registry compose: 1.270007ms
load (parse, merge, extends, references), median of 15: 18.278029ms

load phase                    ms    baseline      delta
json parse                 3.353       1.659    +102.1%
tree build                 9.770       4.338    +125.2%
merge                      0.666       0.278    +139.5%
super resolution           0.175       0.075    +134.0%
validation                 0.000       0.000        n/a
reference resolution       2.946       1.226    +140.3%
freeze                     0.061           -        new

validation passes: none implemented yet

peak memory: 34252 KiB (baseline 100 KiB, +34152.0%)

resolved reads of every node (children, attrs, is_array), first pass fills the cache, median of 15: 3.4451ms
resolved reads of every node, from the cache, median of 15: 61.707µs
canonical serialize, median of 15: 14.237941ms
Evidence: Written baseline file format (--write-baseline output)
{
  "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": 15,
  "phases": {
    "json parse": 3.317,
    "tree build": 8.675,
    "merge": 0.556,
    "super resolution": 0.151,
    "validation": 0.0,
    "reference resolution": 2.451,
    "freeze": 0.059
  },
  "passes": {},
  "peakRssKiB": 34160
}
Evidence: Focused loader timing test result

running 1 test
.
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 9 filtered out; finished in 0.01s

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.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
CI lane prints the per-phase timing table record-only: cargo load_bench 20 15 shows all 7 phases, validation 0.000, 'validation passes: none implemented yet', peak memory, and no baseline/delta column… ✅ pass live local gate evidence (ci-lane-bench-table.txt)
Machine-local baseline workflow round-trips: --write-baseline saves a well-formed record and a follow-up --baseline run renders ms/baseline/delta columns with n/a for the zero validation phase and a p… ✅ pass live local gate evidence (baseline-compare-same-machine.txt) and written-baseline-format.json
Adversarial: the comparison never fails a run — a baseline with halved values and one removed phase produces +100–140% deltas, a '- new' row for the missing phase, +34152% peak-memory delta, and exit… ✅ pass live local gate evidence (adversarial-baseline-run.txt)
Loader-level guarantee: a load through the public Loader API records every phase in order (json parse, tree build, merge, super resolution, validation, reference resolution, freeze) ✅ pass live local gate evidence (loader-timing-test.txt)
  • scripts/ci-local.sh --affected --strict-toolchains
  • scripts/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.json
  • cargo run --release --locked -q --example load_bench -- 20 15 --baseline $DEV_SCRATCH/mo-bench/scratch-baseline.json
  • cargo 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.

…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)
@dmealing
dmealing merged commit cdb4bbf into main Nov 18, 2026
17 of 19 checks passed
@dmealing
dmealing deleted the fm/mo-rust-parity-validation branch November 18, 2026 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant