test(perf): paired peak-RSS harness for the native cache writer (#9584)
Refs #9584.
Head ref updated 2026-11-19: #10361 moved from e8bd18eea to d4658dc8c after its review fixes (no cache bytes changed); the merge base is unchanged.
The acceptance item left on #10361 is a paired peak-RSS run: baseline in-memory, head in-memory and head streamed, on the PR's exact merge base ee77162e03a93591765ea574392a02ba7e66da08 and head d4658dc8c9dacfa5dcf6b1e89c1730e2a6e1b1ef. This is the harness that produces it.
It is deliberately not on #10361's branch. That PR's head is the thing being measured and was verified at that exact sha; committing the harness there would move the head and the run would no longer be of the head it names. The harness builds both refs in throwaway worktrees, so it runs from any branch.
What it does
scripts/perf/cache-stream-ab.mjs — three builds per model, interleaved:
| variant | binary | from |
|---|---|---|
base-inmem | --example conformance_writer | merge base |
head-inmem | --example conformance_writer | head |
head-streamed | --bin ifc-build-cache | head |
The head in-memory control is the point of the third row: without it, every byte the branch moved for any other reason is credited to the streaming writer. base→head-inmem is that confound on its own; head-inmem→head-streamed is the writer's own saving.
Per run it records peak RSS (/usr/bin/time, both dialects), elapsed, the sha256 and size of the written .ifclite, the stats JSON (meshCount, chunkCount, cacheBytes, and the head's chunkCells / peakOpenChunkBytes), and the 1-minute load average before the run.
What it refuses to measure
- Binaries come from
build-at-ref.shworktrees, never the working tree, so an uncommitted edit cannot reach a measurement. - The two refs must pin the same
rust-toolchain.toml; otherwise the run stops, because the comparison would be of two compilers. - Every fixture is hashed on disk and checked against
tests/models/manifest.json. An uncatalogued or altered fixture stops the run. - A
/usr/bin/timesummary with no peak RSS is a failed measurement, not a zero. - Each round orders the three variants by a balanced shuffled rotation (
variantOrder), so no variant always pays the cost of running first — ab-order.mjs's two-sided version of this is what stopped a commit measuring itself 23.5% faster. - A variant that wrote different bytes than the others, or different bytes between its own rounds, fails the run (exit 1) rather than footnoting a memory table.
Host load is recorded around every run but not gated on: whether the host was quiet enough is the admitting operator's call, and the numbers to make it are in the report.
Running it
node scripts/perf/cache-stream-ab.mjs \
--base ee77162e03a93591765ea574392a02ba7e66da08 \
--head d4658dc8c9dacfa5dcf6b1e89c1730e2a6e1b1ef \
--iters 5 --json cache-rss.json
Default models are the two large cases and the small control: various/O-S1-BWK-BIM architectural - BIM bouwkundig.ifc, ara3d/ISSUE_053_20181220Holter_Tower_10.ifc, ara3d/AC20-FZK-Haus.ifc. It prints the markdown report to stdout, ready to attach to #10361.
Evidence
scripts/perf/cache-stream-report.test.mjs: 20 tests over the pure half, including unique kept-output names per model and identity claimed only when observed, — ordering balance and replay, row validation, failed runs kept out of medians, the noise floor, both identity failure modes, real moves outside the acceptance comparison, the incomplete and under-sampled verdicts.- Two declared oracle mutations, because the reporter is a file this PR adds and a derived revert deletes the module the witness imports (
REVERT-BROKE-BUILD, no assertion run).identitymakes byte identity hold unconditionally;noisetakes the floor from the baseline alone. Each ran 16 pass → 15 pass 1 fail on8e6872d45; both patches are regenerated for0a6315a1b, bothOBSERVED, tree restored clean. node scripts/pre-handoff.mjs --base upstream/main: 17 gates PASS, 1 SKIPPED (retained-free viewer—apps/viewer/distabsent, unrelated to this change).- A real end-to-end run on the small control (5 rounds, both refs built from their worktrees), exercising the fixture checksum, the toolchain equality check, the interleaving, the hashing and the report: see the comment below. Those numbers are diagnostic, not acceptance — the host is shared, which is the whole reason the admitted run happens elsewhere.
The run itself and the ledger verdict are not in this PR; the verdict belongs in scripts/perf/README.md on #10361, where that section lives.
🤖 Generated with Claude Code
Summary by CodeRabbit
-
New Features
- Added a benchmark comparing peak memory use across three cache-building approaches, with run details and optional JSON output.
- Added a report summarizing performance differences, measurement noise, output consistency, and incomplete or failed runs.
- Added an option to record the compiler version used for a build.
-
Bug Fixes
- Corrected report handling for differing outputs, measurement noise, and failed runs.
-
Tests
- Added coverage for report accuracy, run validation, output consistency, and performance comparisons.