Skip to content

Add StressPerf.KeyedList /perf macro workload (keyed child-diff path) - #694

Merged
Alexandre Zollinger Chohfi (azchohfi) merged 2 commits into
mainfrom
azchohfi-keyed-list-perf-workload
Jun 26, 2026
Merged

Alexandre Zollinger Chohfi (azchohfi) merged 2 commits into
mainfrom
azchohfi-keyed-list-perf-workload

Conversation

@azchohfi

@azchohfi Alexandre Zollinger Chohfi (azchohfi) commented Jun 26, 2026 •

Copy link
Copy Markdown
Collaborator

Why

The /perf harness only ships StressPerf.ReactorOptimized (StocksGrid), whose cells are positional — they always take ChildReconciler.ReconcilePositional. That leaves the keyed arm (ReconcileKeyed → ReconcileKeyedMiddle, the LIS-based minimal-move machinery) — the target of the keyed-list-diff and the planned keyed structural-skip optimizations — unmeasured. This PR gives /perf a workload that exercises exactly that hot path.

What

A new StressPerf.KeyedList harness: ~500 stably-keyed TextBlock children in a StackPanel that are reordered / inserted / removed every tick (driven by --percent), forcing the keyed reconcile arm and its LIS reorder pass.

It mirrors the StocksGrid harness contract byte-for-byte so the existing orchestration drives it with no special-casing:

  • CLI: --headless --percent <double> --duration <int> --json (shared CliOptions.Parse).
  • Emission (shared PerfTracker, on shutdown): StressPerf.KeyedList.metrics.json + .report.txt + .samples.csv, plus the REACTOR_PERF_JSON {…} stdout line.
  • metrics.json schema: identical (rendersPerSec, avgReconcileMs, avgDiffMs, avgMemoryMB, totalRenders, durationSeconds + allocBytesPerRender, gen0/1/2, gen0PerKRenders, avgFps, sampleCount).
  • Phase capture: Host.OnRenderComplete → PerfTracker.RecordPhases, gated by a pending flag.

Only the scene and its per-tick mutation differ.

Keyed-path guarantee & all-match floor

  • Verified by construction: every child carries a stable non-null Key, so ChildReconciler.HasAnyKeys is definitionally true and the scene always takes ReconcileKeyed. A one-time fail-loud self-check scans the emitted child array and Environment.FailFasts (after a FATAL stderr line, before any metrics.json is written) if any child lacks a Key — so a DSL slip onto ReconcilePositional can never silently report bogus "keyed" numbers.
  • Genuine middle reordering: the per-tick mutation does random interior remove+insert across the whole list (not tail-only churn), so head/tail fast-paths don't absorb it and ReconcileKeyedMiddle's LIS does real work.
  • --percent 0 = the keyed all-match floor: at 0% no edits are applied, so all keys match in place (LIS == whole list, zero moves) — the floor the keyed structural-skip optimization targets. A fresh snapshot array is still allocated each tick, so a render + keyed diff still runs.

Footprint — additive & disjoint

  • New project only + a Reactor.slnx registration. The data source (KeyedListSource) lives inside the new project.
  • No src/Reactor changes (no runtime changes).
  • No harness-orchestration changes (perf-compare.yml / Run-PerfBenchmark.ps1 / PerfLib.ps1 are untouched — owned by the perf-harness wiring PR, which will register this workload separately).
  • The existing StocksGrid workload is untouched.

Validation (headless, ARM64 self-contained — the artifact CI runs)

  • Reactor.csproj and the new project both build 0 warning / 0 error.
  • metrics.json emits every field, including the allocation set; the keyed-path self-check passes on every run (exit 0, no FATAL).
  • Cost concentrates in the keyed child-diff phase: avg diff is ~99% of avg reconcile (avg tree ≈ 0.1 ms).
  • Diff scales with reorder volume: avg diff ms 0.64 @ 0% (all-match floor) → 6.61 @ 50% → ~8 @ 90% — a ~10× range a positional diff cannot produce, confirming the keyed LIS path is exercised.

Draft until the perf-harness wiring PR registers this workload and confirms it produces sane /perf output.

The /perf harness only ships StressPerf.ReactorOptimized (StocksGrid), whose
cells are POSITIONAL and always take ChildReconciler.ReconcilePositional. That
leaves the KEYED arm (ReconcileKeyed -> ReconcileKeyedMiddle, the LIS-based
minimal-move machinery) -- the target of keyed-list-diff and keyed
structural-skip optimizations -- unmeasured.

This adds StressPerf.KeyedList: ~500 stably-keyed TextBlock children in a
StackPanel that are REORDERED / INSERTED / REMOVED each tick (driven by
--percent), forcing the keyed reconcile arm and its LIS reorder pass. It mirrors
the StocksGrid harness contract byte-for-byte -- same CLI flags
(--headless/--percent/--duration/--json via the shared CliOptions), same shared
PerfTracker emission (metrics.json + report.txt + samples.csv + the
REACTOR_PERF_JSON stdout line), and the same OnRenderComplete phase capture --
so Run-PerfBenchmark.ps1 / PerfLib.ps1 drive it identically; only the scene and
its per-tick mutation differ.

Additive and disjoint: new project + a Reactor.slnx registration only. No
changes to src/Reactor (no runtime changes) and no changes to the harness
orchestration (perf-compare.yml / Run-PerfBenchmark.ps1 / PerfLib.ps1). The
StocksGrid workload is untouched.

Validated headless (ARM64 self-contained, the artifact CI runs): Reactor.csproj
and the new project build 0 warning / 0 error; metrics.json emits every field
incl. the allocation set; avg diff is ~99% of avg reconcile (tree ~0.1ms),
confirming cost concentrates in the keyed child-diff phase; and avg diff ms
scales with reorder volume (2.29ms @2% -> 6.14 @50% -> 8.01 @90%), which a
positional diff cannot do.

Co-authored-by: Copilot <[email protected]>
…, README entry

- Add a one-time structural self-check that fails loudly (Environment.FailFast)
  if any emitted child lacks a Key, guarding against a DSL slip silently
  falling onto ChildReconciler.ReconcilePositional and measuring the wrong path.
- Let --percent 0 produce the keyed all-match floor (k clamps to [0, N] instead
  of [1, N]); validated avgDiffMs 0.64ms @0% vs 6.61ms @50%, isolating the
  structural-skip floor for the keyed optimization work.
- List StressPerf.KeyedList in the stress_perf README workload enumeration.

Co-authored-by: Copilot <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new /perf macro workload (StressPerf.KeyedList) that specifically exercises Reactor’s keyed child reconciliation path (the ReconcileKeyed* / LIS minimal-move machinery) which the existing StocksGrid workload cannot reach, enabling perf measurement for keyed-diff optimizations without modifying src/Reactor.

Changes:

  • Introduces a new stress-perf harness project (StressPerf.KeyedList) that renders ~500 stably-keyed children and performs reorder/insert/remove mutations per tick.
  • Hooks the harness into the existing stress-perf contract (shared CliOptions, shared PerfTracker emission, OnRenderComplete phase capture) and registers it in Reactor.slnx.
  • Updates tests/stress_perf/README.md to document the new workload alongside existing variants.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/stress_perf/StressPerf.KeyedList/StressPerf.KeyedList.csproj New WinUI/AOT stress-perf executable project, mirroring the existing perf CI self-contained gating pattern.
tests/stress_perf/StressPerf.KeyedList/Program.cs Harness app wiring: CLI parse, perf phase capture, tick loop, keyed TextBlockElement scene construction.
tests/stress_perf/StressPerf.KeyedList/KeyedListSource.cs Deterministic keyed-list mutation source (reorder + churn) producing stable keys and content-stable labels.
tests/stress_perf/README.md Documents the new keyed-list workload and its intent.
Reactor.slnx Registers the new stress-perf project in the solution for build/CI inclusion.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@azchohfi
Alexandre Zollinger Chohfi (azchohfi) marked this pull request as ready for review June 26, 2026 08:28
@azchohfi
Alexandre Zollinger Chohfi (azchohfi) merged commit 283780a into main Jun 26, 2026
19 checks passed
Alexandre Zollinger Chohfi (azchohfi) added a commit that referenced this pull request Jun 26, 2026
…698)

* perf(ci): wire StressPerf.KeyedList into /perf as a third macro leg

Add the already-merged (#694) StressPerf.KeyedList workload to the /perf
comparison as a third interleaved A/B macro leg, so /perf can resolve
keyed-diff optimizations the positional StocksGrid cells never exercise.

StocksGrid (StressPerf.ReactorOptimized) mutates cells in place by index, so
its child diff always takes ChildReconciler.ReconcilePositional. The keyed
LIS arm (ReconcileKeyed -> ReconcileKeyedMiddle) is invisible to it by
construction -- the same blind spot that made the headline-only comparison
unable to resolve keyed work (P2/#657, keyed structural-skip P4-C2).
StressPerf.KeyedList renders ~500 stably keyed rows reordered/inserted/
removed each tick, driving that keyed arm on every tick.

Harness changes (measurement tooling only; 0 src/Reactor):
- Run-PerfBenchmark.ps1: AppRegistry KeyedList entry; -IncludeKeyedList
  (default on) + 'KeyedList' in the local -Apps set; best-effort build
  (try/catch -> omit on failure, like micro); third interleaved leg at the
  headline -Percent with the same pair-aligned drop-both collection and full
  Warmup+Reps budget; aggregation, ctx samples, result.json, and
  Format-PerfComment threading.
- PerfLib.ps1: Format-PerfKeyedListSection (renders the 4 headline metrics
  with the same paired-delta 95% CI / direction-aware status as the headline
  table; empty when either side is null); Format-PerfComment -MainKeyed/
  -PrKeyed params, rendered after the Allocation table and before the micro
  suite.
- Tests: PerfLib.Tests.ps1 (216 assertions) + RunPerfBenchmark.Tests.ps1
  (34 assertions) cover the new section + the static wiring contract.
- Docs: README params table + "The comment" bullet; METHODOLOGY subsection;
  perf-compare.yml header + timeout 60 -> 75 (third macro leg + build).

Verified: both test suites green; a local Run-PerfBenchmark.ps1 smoke (stub
harness exes on this ARM64/OneDrive box) renders the keyed table in the right
position with a direction-correct paired delta, and omits it under
-IncludeKeyedList:$false.

Co-authored-by: Copilot <[email protected]>

* perf(ci): address pr-review findings on the keyed-list leg

Internal pr-review (8 dimensions + multi-model cross-check) on #698 surfaced
1 low + 3 medium, all confirmed by the cross-check, all in this PR's own
tooling/tests. No critical/high. Addressed:

- api-ergonomics (low): the run-mode log line printed `keyed-list={on/off}`
  from -IncludeKeyedList even in LOCAL mode, where the workload set actually
  comes from -Apps (so a default local run logged keyed-list=on while not
  running KeyedList). Make the mode line mode-aware: COMPARE keeps
  skip-floor/keyed-list tied to the include switches; LOCAL reports
  `apps=<-Apps>` instead.
- test-coverage (medium x3) in the keyed leg's tests:
  * RunPerfBenchmark.Tests.ps1: lock the opt-out + best-effort build fallback
    (build guarded by -IncludeKeyedList; a build failure flips it $false; the
    run leg is skipped when off) and the one-sided-failure drop-both pair
    alignment ($mm -and $pm appends both; $mm -or $pm drops both).
  * PerfLib.Tests.ps1: assert keyed verdicts for ALL four headline metrics --
    add Avg Diff (improvement) and Avg Memory (within noise). The keyed fixture
    now gives memory a small symmetric per-pair jitter so its paired CI
    straddles 0 (a proper within-noise case, not a degenerate zero-variance
    delta).

PerfLib.Tests.ps1 218/218 (+2), RunPerfBenchmark.Tests.ps1 39/39 (+5); all
four scripts parse clean; 0 src/Reactor.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
Alexandre Zollinger Chohfi (azchohfi) added a commit that referenced this pull request Jun 26, 2026
…nd (#704)

Closes the silent-omit class on the /perf comment: the micro-suite and keyed-list legs now surface a loud "N/16 - incomplete (reason)" note instead of silently rendering nothing when a leg times out or is lineage-absent.

- Loud incompleteness: micro section emits "micro: N/16 - incomplete (reason)" + per-site omit assertions; keyed-lineage-omit note added (PR tree predates #694 -> rebase to populate).
- Fixes a real bug caught in review: MicroExpectedBenchCount was 13 but BenchCatalog.All emits 16 (M1-M13 + OAlloc/OUpdate/C207), so a 13-of-16 run read "complete". Now 16, with a drift-guard test parsing BenchCatalog.All so the mirror cannot silently drift.
- (d) alloc-band recalibration: MicroIterations 1000->2000 (steadies per-op alloc variance; fits the per-round 180s budget) + MicroAllocMinEffectPct 1.0->3.0 provisional hedge (<= ns band), test-locked; precise band is the post-merge identical-binary calibration.
- ns auto-flag remains DORMANT ($false).

Class-B: 5 files all tests/stress_perf/ci/**, 0 src/Reactor.

Co-authored-by: Copilot <[email protected]>
Alexandre Zollinger Chohfi (azchohfi) added a commit that referenced this pull request Jun 26, 2026
…ff-skip + DSL allocs) (#711)

Adds M14_DslRebuildCascade to the PerfBench.ControlModel micro-suite. Each
iteration rebuilds a 300-leaf tree through a deep fluent-modifier cascade
(.FontSize/.Bold/.Foreground/.Padding/.Margin/.Width/.Height/.Opacity + .Set)
with no memoization, then reconciles it against the structurally-equal prior
tree (a rotating ~1/16 of cells mutate). This isolates PR #665's two effects --
the DSL/element per-render alloc cut and the SettersEqual diff-skip restore --
which every existing instrument either pre-empts (the StocksGrid macro memoizes
cells via UseMemoCellsByIndex and bypasses the cascade) or never exercises (no
M1-M13 / OAlloc / OUpdate micro rebuilds a deep fluent + .Set tree and re-diffs
it against an equal prior tree). This is the #665 analogue of PR #694's
keyed-list workload.

Bumps the loud-incompleteness guard (MicroExpectedBenchCount 16 -> 17) and its
drift-guard test so the 17th bench does not trip a false "N/16 Incomplete" note.

Purely additive harness/test code under tests/; no src/Reactor changes.

Local sensitivity read (M14 Reactor variant, iterations=1000, Release ARM64),
applying only #665's 4 src files then reverting:
  WITHOUT #665: 3,500,897 B/op
  WITH    #665: 2,816,897 B/op   (-684,000 B/op, -19.5%; deterministic each rep)
confirming M14 resolves #665's DSL-cascade allocation cut.

Co-authored-by: Copilot <[email protected]>
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.

3 participants