Repository navigation
perf(ci): wire reconciler micro-suite into /perf (ns + alloc, Core layer) - #693
Merged
Alexandre Zollinger Chohfi (azchohfi) merged 6 commits intoJun 26, 2026
Merged
Conversation
…yer) The /perf macro StocksGrid leg is render-bound and working-set diluted: rps is ~76% gated by the WinUI render thread and the reconcile/diff/alloc figures are measured across a live render pipeline, so it cannot resolve the small Core/Reconciler deltas the perf fleet actually targets. The repo already ships a purpose-built ns-resolution micro-suite (tests/perf_bench/PerfBench.ControlModel, spec-047 M1-M13) that brackets only the reconcile body with per-thread alloc + GC counters — and /perf ignored it. This wires it in. What it adds: - PerfBench.ControlModel builds self-contained per side (scoped, opt-in PerfCiSelfContained knob; unpackaged WindowsPackageType=None so it builds on the runner without the packaged-app MakePri path). main and PR each link their own src/Reactor, so the per-bench delta is a clean read on the code change. - A new micro section in the sticky comment: per-bench `main` vs PR ns/op + B/op with the same paired 95% CI machinery as the macro tables. - Run-PerfBenchmark.ps1 orchestration: -IncludeMicro/-MicroReps/-MicroIterations, best-effort build+run+compare after the Rust leg, threaded into the comment and result.json. Any micro failure leaves the macro comment untouched. v1 flagging — alloc-driven, ns informational: Local validation (running the SAME ControlModel binary as both "main" and "PR") showed allocated bytes/op is deterministic (14/16 benches exactly 0.0% delta) but ns/op is NOT: with the two per-side runs not yet rep-interleaved, a systematic process-to-process timing offset shifts every paired ns difference the same way and makes the paired CI exclude 0 even for an identical binary (one bench spuriously read -14.8% ns). So the row Status tracks the deterministic alloc signal; ns/op is shown for context but not auto-flagged. Rep-level interleaving of the two sides is the documented fast-follow that would promote ns to a flag. Why this matters (n=12 local analysis, see the PR2 description): the previous /perf path was reconcile- and alloc-blind on the macro workload — rps is ~76% render-bound, the old 4% floor preordained every sub-4% verdict as "noise", and there was no allocation instrument for the layer most fleet PRs optimize. The micro-suite is the authoritative per-reconcile allocation instrument; the macro tables remain the user-facing throughput sanity check. Tests: PerfLib.Tests.ps1 +46 micro assertions (162 total) incl. a no-false-flag property bench (clear ns improvement + unchanged alloc -> row reads noise); RunPerfBenchmark.Tests.ps1 unchanged-green (21). Docs: ci/README.md + METHODOLOGY.md document the micro leg and the alloc-flagged/ns-informational v1. File-disjoint from src/Reactor and the perf fleet. Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
Wires the existing PerfBench.ControlModel reconciler micro-benchmark suite into the /perf CI harness so perf-compare reports WinUI-undiluted Core/Reconciler deltas (ns/op + B/op) alongside the existing StocksGrid macro workload.
Changes:
- Adds an opt-in micro-benchmark leg to
Run-PerfBenchmark.ps1that builds/runsPerfBench.ControlModelper side and threads results intocomment.mdandresult.json. - Extends
PerfLib.ps1with JSONL parsing, paired-CI comparison, and markdown rendering for the micro-suite section. - Documents the methodology/interpretation (alloc drives status; ns informational until rep-level interleaving) in
ci/README.mdandMETHODOLOGY.md, and adds unit coverage inPerfLib.Tests.ps1.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/stress_perf/METHODOLOGY.md | Documents why/when micro-benches are needed and how to interpret ns vs alloc in v1. |
| tests/stress_perf/ci/Run-PerfBenchmark.ps1 | Orchestrates best-effort build/run/compare of the micro-suite and threads it into outputs. |
| tests/stress_perf/ci/README.md | Adds user-facing harness docs for the micro-benchmark leg and new flags. |
| tests/stress_perf/ci/PerfLib.Tests.ps1 | Adds unit tests for parsing/comparison/rendering and “no false flag” status behavior. |
| tests/stress_perf/ci/PerfLib.ps1 | Adds micro-suite parsing/comparison and integrates micro section into the sticky comment. |
| tests/perf_bench/PerfBench.ControlModel/PerfBench.ControlModel.csproj | Adds PerfCiSelfContained knob to allow self-contained CI builds on the runner. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…t discard Two correctness fixes from the PR #693 Copilot review: 1. Read-MicroBenchResults now tags each sample with its repetition index, and Get-PerfMicroComparison pairs the two sides BY REPETITION rather than by array position. Previously a dropped/errored repetition on one side (its row filtered out) compacted the arrays, so every later sample shifted left and the paired CI compared main rep i against pr rep i+1 — silently mis-pairing. This mirrors the macro path's null-placeholder defense. New regression test: main has reps 0..3 (rep1 an outlier), pr is missing rep1 → the paired alloc Δ resolves to the clean -10% over the common reps {0,2,3} instead of being smeared by the mismatch. 2. Invoke-MicroRun now discards any output on timeout and returns $null. The bench writes results.jsonl incrementally (one line per rep, flushed between benches), so a killed run leaves a truncated prefix subset; accepting it would compare a silent subset of benches/reps. A timeout now omits the micro section instead. Tests: PerfLib.Tests.ps1 168 assertions (was 162); RunPerfBenchmark.Tests.ps1 21. Real-data happy path unchanged (full rep intersection → identical result). Co-authored-by: Copilot <[email protected]>
… medians Two follow-up fixes from the PR #693 re-review: 1. Invoke-MicroRun now also discards output when the harness exits non-zero (not only on timeout). A clean run exits 0 — per-bench exceptions are caught and written as a filtered status:"error" row, so they don't fail the process — so a non-zero exit means a crash, and because results.jsonl is written incrementally that leaves a truncated prefix. Discard it rather than compare a silent subset. 2. Get-PerfMicroComparison now computes the DISPLAYED medians (MainMeanNs / PrMeanNs / MainAllocBytes / PrAllocBytes) over the SAME rep-aligned sample set used for the paired CI, instead of over all per-side samples. Previously, when a repetition was missing on one side, the table's main/PR columns and its Δ could be drawn from different reps. New test bench A2: main's unpaired rep sits at the ns median position, so the displayed median must be 20 (aligned {0,2,3}) not 25 (all four). Tests: PerfLib.Tests.ps1 172 assertions (was 168); RunPerfBenchmark.Tests.ps1 21. Real-data happy path unchanged (full rep intersection -> identical medians/Δ). Co-authored-by: Copilot <[email protected]>
…n-effect band Addresses the pr-review skill findings + a gate-5 smoke finding on real PerfBench.ControlModel data (16 benches x 6 reps, identical binary A/B): F2 (must-fix): Get-PerfMicroComparison flagged better/worse off the point-delta fallback when < 2 rep-aligned pairs survive (Get-PerfPairedDeltaStats returns $null). Add -RequirePairedCI to Get-PerfDelta: with no admissible paired CI the micro path now returns 'na' (N=$null) instead of a one-sample flag. Macro path keeps the legacy fallback (switch defaults off). F1: alloc was displayed as B/op but allocBytes is the per-rep loop TOTAL while meanNs is per-op. Read-MicroBenchResults now divides allocBytes by the row's iterations so the B/op column and per-op ns share one basis (M1: 4,474,872 / 4000 = 1118.7 B/op). Constant divisor preserves determinism. Minimum-effect band (gate-5 smoke): not every micro bench is alloc-deterministic — dispatcher / background-thread benches (M5 "Dispatch_Switch_Warm" measured 6/6 distinct alloc values per rep) carry a sub-1% systematic process-to-process offset that the within-process CI can't cancel, so the tight CI excluded 0 and false-flagged 'worse' at +0.3% on identical code. Add -MinEffectPct to Get-PerfDelta: the micro ALLOC delta now flags only when the 95% CI clears a +-1% band (real structural alloc changes are several percent to many-x; RECON's ~3KB/cell fix is far above it). This is a CI-vs-band test on the non-interleaved micro alloc metric, NOT the blanket point-delta floor PR1 removed. ns stays informational-only (pure CI-excludes-0). Band documented in the rendered section preamble. F4: add .PARAMETER help for IncludeMicro / MicroReps / MicroIterations. F5: cover Invoke-MicroRun discard paths (timeout, non-zero exit, empty output). F6: lock 0/1-common-rep -> 'na' behavior. Tests: PerfLib.Tests.ps1 188 assertions, RunPerfBenchmark.Tests.ps1 25 assertions, both green. Smoke on real jsonl: all 16 benches read noise/na (no false flag), per-op alloc cross-checked against raw median/iterations. Measurement-tooling only; zero src/Reactor changes. Co-authored-by: Copilot <[email protected]>
Copilot review on 67d0e57: the Start-Process / Start-Sleep stubs were removed only on the straight-line path, so a throwing assertion would skip cleanup and leak the stubs into the rest of the script. Move the removals into a finally so teardown is deterministic regardless of assertion outcome. No assertion change (still 25 green). Co-authored-by: Copilot <[email protected]>
Copilot review on 7ed6ba9: Read-MicroBenchResults required benchId/meanNs/ allocBytes but not repetition, yet it sorts by and casts [int]\.repetition. A row missing repetition (schema drift / truncation) or with a non-numeric value would throw PAST the malformed-line guard and break /perf comment generation, contradicting the 'malformed lines are skipped' contract. Require the property and validate the [int] cast at ingestion; skip the row if it won't parse. Adds 4 assertions (missing + non-numeric repetition both dropped, surviving reps are the valid ones, no throw). 192 green; real-data smoke still parses 16 benches. Co-authored-by: Copilot <[email protected]>
Alexandre Zollinger Chohfi (azchohfi)
marked this pull request as ready for review
June 26, 2026 09:01
Alexandre Zollinger Chohfi (azchohfi)
requested a review
from Chris Anderson (codemonkeychris)
as a code owner
June 26, 2026 09:01
This was referenced Jun 26, 2026
Alexandre Zollinger Chohfi (azchohfi)
deleted the
azchohfi-perf-microsuite
branch
June 26, 2026 16:28
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.
What & why
/perfmeasures only the StocksGrid macro workload, which is the wrong instrument for the Core/Reconciler layer most of the perf fleet optimizes. This PR (PR2 of the harness-improvement split; PR1 #691 added reps + paired-CI + a coarse process-wide alloc metric) wires in the existingPerfBench.ControlModelmicro-suite (spec-047 M1–M13) so/perfalso reports per-bench, ns-resolution, WinUI-undilutedmain-vs-PRns/op+B/op— the layer the fleet actually operates on, which/perfpreviously ignored.Methodology rationale (local n=12 analysis)
The macro path could not resolve the deltas the fleet produces:
renders/sec −0.6%reproduces its sign only 23% of the time (74% of 2v2 medians show PR faster).The micro-suite brackets only the reconcile body with per-thread alloc + GC counters (no render pipeline), so it resolves exactly what the macro path cannot.
What this adds
PerfBench.ControlModelbuilds self-contained per side — a scoped, opt-inPerfCiSelfContainedMSBuild knob (unpackagedWindowsPackageType=None, so it builds on the runner without the packaged-app MakePri path).mainand the PR each link their ownsrc/Reactor, so the per-bench delta is a clean read on the code change.mainvs PRns/op+B/opwith the same paired 95% CI machinery as the macro tables.Run-PerfBenchmark.ps1orchestration:-IncludeMicro(default on) /-MicroReps 12/-MicroIterations 10000; best-effort build + run + compare after the Rust leg; threaded into the comment andresult.json. Any micro failure leaves the macro comment untouched.v1 flagging — alloc-driven, ns informational
I validated the leg end-to-end on this ARM64 box by running the same ControlModel binary as both "main" and "PR" (a true no-op diff). Result:
Sample comment section (rendered from the identical-binary validation run — note
M3reads −14.8% ns yet the row correctly stays "within noise" because alloc is unchanged):Rep-level interleaving of the two sides is the documented fast-follow that would promote ns to a flagged signal. (Per the coordinator's calibration: PR1's process-wide alloc = coarse macro trend; this micro-suite = the authoritative, WinUI-undiluted per-reconcile alloc instrument.)
Tests & docs
PerfLib.Tests.ps1: +46 micro assertions (162 total), including a no-false-flag property bench (clear ns improvement + unchanged alloc ⇒ row readsnoise) and alloc-only row-status precedence.RunPerfBenchmark.Tests.ps1: unchanged-green (21).ci/README.md+METHODOLOGY.md: document the micro leg and the alloc-flagged / ns-informational v1 (with the empirical no-op finding and the interleaving fast-follow).File-disjoint from
src/Reactorand the perf fleet — touches onlytests/perf_bench/PerfBench.ControlModel/*andtests/stress_perf/**. No/perfrun is needed on this PR (it changes/perfitself); the fleet gets re-run after this lands.Draft until reviewed.