Repository navigation
perf: re-validate #654 COM-interop coalescing on current main (double-check #666 no-op) - #769
Alexandre Zollinger Chohfi (azchohfi) wants to merge 1 commit into
Conversation
…date #654) Re-applies PR #666 (closed as an 'honest no-op') onto current main to independently re-measure via CI /perf. Squash-merge of azchohfi-reconciler-interop-perf; the single Reconciler.cs conflict in ApplyResourceOverrides resolved in favor of main's #675 removal-guard fix (drop the oldOverrides!=null gate) while keeping the perf #26 deferred-removal loop body. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
/perf |
|
|
||
| // Same instance recorded and current: object.Equals(x, x) == true via the | ||
| // ReferenceEquals short-circuit even though x.Equals(x) == false. Match it exactly. | ||
| Assert.Equal(object.Equals(x, x), NonReflexiveCtx.CurrentValueEquals(scope, x)); |
| foreach (var c in GetChildren(el)) | ||
| { | ||
| if (c is null or EmptyElement) continue; | ||
| children.Add(c); | ||
| if (childText is null && c is TextBlockElement tb) | ||
| childText = tb.Content; | ||
| } |
⚡ Reactor perf comparisonWorkload: Regression vs
|
| Metric | main (baseline) |
This PR | Δ (95% CI) | Status |
|---|---|---|---|---|
| Renders/sec ↑ | 2.71 | 2.61 | -0.2% 95% CI [-4.9, +4.6] | ≈ within noise |
| Avg Reconcile (ms) ↓ | 123.5 | 124.1 | +0.8% 95% CI [-2.9, +4.6] | ≈ within noise |
| Avg Diff (ms) ↓ | 113.1 | 113.4 | -0.5% 95% CI [-4.3, +3.3] | ≈ within noise |
| Avg Memory (MB) ↓ | 283.5 | 283.7 | -0.1% 95% CI [-0.8, +0.6] | ≈ within noise |
Low-mutation skip-floor (--percent 0)
At --percent 0 the workload mutates few cells per tick (always at least one), so reconcile/diff isolate the O(n) per-tick child skip-walk floor that higher mutation rates dilute — ChildReconciler re-walks every child each tick even when nothing moved. The closer --percent is to 0, the more this floor is the signal, so a structural-skip optimization shows up cleanly where the headline table above buries it. Δ is the mean paired change with a 95% CI.
| Metric | main (baseline) |
This PR | Δ (95% CI) | Status |
|---|---|---|---|---|
| Renders/sec ↑ | 15.83 | 15.17 | 0.0% 95% CI [-5.5, +5.5] | ≈ within noise |
| Avg Reconcile (ms) ↓ | 35.3 | 35.5 | +0.7% 95% CI [-4.9, +6.3] | ≈ within noise |
| Avg Diff (ms) ↓ | 33.1 | 33.3 | +0.8% 95% CI [-5.2, +6.9] | ≈ within noise |
| Avg Memory (MB) ↓ | 265.7 | 265.5 | -0.1% 95% CI [-0.5, +0.2] | ≈ within noise |
Allocation (Reactor) — lower is better
| Metric | main (baseline) |
This PR | Δ (95% CI) | Status |
|---|---|---|---|---|
| Alloc bytes/render ↓ | 4855932 | 4927609 | +1.3% 95% CI [-0.3, +2.9] | ≈ within noise |
| Gen0 GC / 1k renders ↓ | 200.00 | 220.11 | +9.1% 95% CI [-1.3, +19.5] | ≈ within noise |
Keyed-list workload (StressPerf.KeyedList, --percent 50)
A separate macro workload: a ~500-row stably keyed list whose rows are reordered / inserted / removed each tick. Because every child carries a key, the child reconciler takes its keyed arm (ReconcileKeyed → ReconcileKeyedMiddle, the LIS-based minimal-move pass) instead of the positional re-walk the StocksGrid tables above measure — so this is the sensitive macro signal for keyed-diff work the positional cells can never reach. Same interleaved paired-Δ 95% CI as the headline table.
| Metric | main (baseline) |
This PR | Δ (95% CI) | Status |
|---|---|---|---|---|
| Renders/sec ↑ | 18.13 | 17.92 | -1.9% 95% CI [-6.7, +3.0] | ≈ within noise |
| Avg Reconcile (ms) ↓ | 19.0 | 19.0 | +0.6% 95% CI [-4.6, +5.7] | ≈ within noise |
| Avg Diff (ms) ↓ | 18.9 | 18.8 | +0.6% 95% CI [-4.6, +5.7] | ≈ within noise |
| Avg Memory (MB) ↓ | 167.3 | 167.0 | -0.2% 95% CI [-1.1, +0.7] | ≈ within noise |
Allocation (keyed-list) — lower is better
| Metric | main (baseline) |
This PR | Δ (95% CI) | Status |
|---|---|---|---|---|
| Alloc bytes/render ↓ | 215668 | 210619 | -2.4% 95% CI [-2.6, -2.1] | ✅ improvement |
| Gen0 GC / 1k renders ↓ | 10.78 | 10.90 | +2.4% 95% CI [-2.5, +7.4] | ≈ within noise |
Flex/Yoga layout workload (StressPerf.Flex, --percent 50)
A separate macro workload: a deep nested, fully-realized (non-virtualized) flex tree (~2000 leaf cells) whose per-child flex inputs (grow / basis / width) are re-rolled on a --percent fraction of the leaves each tick, forcing a real Yoga measure/layout pass every frame while the unchanged leaves re-push identical inputs (the YogaNode setter-equality-guard / layout-cache-hit path). This drives the FlexPanel / Yoga LAYOUT engine — the sensitive macro signal for Yoga/Flex layout-engine allocation + memory work the positional StocksGrid and keyed-list legs can never reach. Same interleaved paired-Δ 95% CI as the headline table.
Reading this table: the reconcile / diff timing rows do not capture the deferred Yoga Measure/Arrange pass — it runs after the harness'
OnRenderCompletephase hook, inFlexPanel.MeasureOverride/ArrangeOverride. Judge layout-engine wins primarily on the flex allocation table below (process-wide GC counters capture the whole run, layout pass included) and the renders-per-second figure. The working-set memory figure is informational only — too coarse to resolve inline-per-node-array gains at this node count.
| Metric | main (baseline) |
This PR | Δ (95% CI) | Status |
|---|---|---|---|---|
| Renders/sec ↑ | 1.02 | 1.04 | -0.4% 95% CI [-9.9, +9.0] | ≈ within noise |
| Avg Reconcile (ms) ↓ | 167.9 | 163.2 | -0.3% 95% CI [-4.5, +3.9] | ≈ within noise |
| Avg Diff (ms) ↓ | 156.5 | 151.1 | -1.3% 95% CI [-5.4, +2.9] | ≈ within noise |
| Avg Memory (MB) ↓ | 236.1 | 234.3 | -0.5% 95% CI [-3.8, +2.8] | ≈ within noise |
Allocation (flex) — lower is better
| Metric | main (baseline) |
This PR | Δ (95% CI) | Status |
|---|---|---|---|---|
| Alloc bytes/render ↓ | 8393109 | 8365353 | -0.5% 95% CI [-1.5, +0.5] | ≈ within noise |
| Gen0 GC / 1k renders ↓ | 454.55 | 461.54 | -0.9% 95% CI [-8.5, +6.8] | ≈ within noise |
DataGrid control workload (StressPerf.DataGrid, --percent 50)
A separate macro workload: the real DataGrid control (DataGridComponent) over a 30-column × 200-row IObservableDataSource whose cells are mutated on a --percent fraction each tick, forcing a full DataGridComponent.Render() every frame. This re-runs — unconditionally, regardless of whether sort/filter changed — the per-render array/LINQ rebuilds (#663/#669) and re-allocates the per-realized-cell/row .OnTapped/.OnPointerPressed closures (#671) that the StocksGrid, keyed-list and flex legs never reach. Same interleaved paired-Δ 95% CI as the headline table.
Reading this table: the DataGrid's re-render is async / dispatcher-debounced (
DataChanged→LoadDataAsync→ coalescedforceRender+ a scroll-settle timer), so the reconcile / diff timing rows are noisier here and a render may be coalesced. Judge DataGrid allocation / delegate wins primarily on the DataGrid allocation table below (process-wide GC counters capture the whole run) and the renders-per-second figure. The working-set memory figure is informational only.
| Metric | main (baseline) |
This PR | Δ (95% CI) | Status |
|---|---|---|---|---|
| Renders/sec ↑ | 4.75 | 4.89 | +2.3% 95% CI [-0.5, +5.0] | ≈ within noise |
| Avg Reconcile (ms) ↓ | 99.8 | 96.1 | -3.4% 95% CI [-7.3, +0.5] | ≈ within noise |
| Avg Diff (ms) ↓ | 99.7 | 95.9 | -3.4% 95% CI [-7.3, +0.5] | ≈ within noise |
| Avg Memory (MB) ↓ | 269.8 | 270.5 | +0.3% 95% CI [-0.2, +0.8] | ≈ within noise |
Allocation (datagrid) — lower is better
| Metric | main (baseline) |
This PR | Δ (95% CI) | Status |
|---|---|---|---|---|
| Alloc bytes/render ↓ | 13144851 | 13112789 | -0.1% 95% CI [-0.4, +0.2] | ≈ within noise |
| Gen0 GC / 1k renders ↓ | 166.67 | 161.63 | -1.8% 95% CI [-6.5, +2.9] | ≈ within noise |
Reconciler micro-benchmarks (PerfBench.ControlModel)
Production --variant Reactor control-model path, ns-resolution and WinUI-undiluted (spec-047 M1–M13) — ↓ lower is better. Status tracks allocated bytes/op, the authoritative signal here; it is deterministic for structurally-fixed benches, while dispatcher / background-thread benches carry a small process-to-process offset, so a bench is flagged only when its 95% CI clears a ±3% minimum-effect band (real structural alloc changes are several percent to many-x). ns/op is shown for context but is not auto-flagged (its paired CI is rep-interleaved but the flag remains dormant pending a real-CI identical-binary band calibration). Δ is the mean paired change with a 95% CI.
| Bench | main ns/op |
Δ ns (95% CI) | main B/op |
Δ alloc (95% CI) | Status |
|---|---|---|---|---|---|
M1 Mount_Leaf_NoCallback |
149697.6 | -1.4% 95% CI [-2.3, -0.5] | 1140.9 | 0.0% 95% CI [0.0, 0.0] | ≈ within noise |
M2 Mount_Leaf_OneCallback |
106762.2 | +1.5% 95% CI [-2.7, +5.7] | 3383.3 | 0.0% 95% CI [0.0, 0.0] | ≈ within noise |
M3 Mount_Leaf_ThreeCallbacks |
212119.2 | -0.1% 95% CI [-4.1, +3.9] | 8446.8 | +0.4% 95% CI [-1.7, +2.4] | ≈ within noise |
M4 Dispatch_Switch_Cold |
103674.6 | -0.9% 95% CI [-5.3, +3.4] | 1767.8 | 0.0% 95% CI [0.0, 0.0] | ≈ within noise |
M5 Dispatch_Switch_Warm |
104693.6 | +0.2% 95% CI [-5.1, +5.5] | 1766.0 | +1.1% 95% CI [-0.3, +2.4] | ≈ within noise |
M6 Dispatch_ExternalType |
91692.8 | +3.8% 95% CI [-3.1, +10.7] | 987.6 | +2.1% 95% CI [-0.3, +4.5] | ≈ within noise |
M7 Update_NoChange |
55927.9 | +3.5% 95% CI [-2.2, +9.2] | 452.1 | -4.5% 95% CI [-9.7, +0.7] | ≈ within noise |
M8 Update_OneLeafChanged |
41980.7 | -0.5% 95% CI [-1.3, +0.3] | 536.0 | 0.0% 95% CI [0.0, 0.0] | ≈ within noise |
M9 Update_AllChanged |
2836808.0 | -0.1% 95% CI [-0.9, +0.8] | 184278.1 | 0.0% 95% CI [0.0, 0.0] | ≈ within noise |
M10 EventHandlerState_Alloc |
86059.2 | -1.3% 95% CI [-2.7, +0.2] | 3095.2 | 0.0% 95% CI [-0.1, +0.2] | ≈ within noise |
M11 ModifierEHS_Frequency |
46140.4 | -1.7% 95% CI [-3.6, +0.2] | 638.9 | 0.0% 95% CI [-0.1, +0.1] | ≈ within noise |
M12 Pool_Rent_HotPath |
119098.2 | -1.8% 95% CI [-2.7, -1.0] | 1099.9 | 0.0% 95% CI [0.0, 0.0] | ≈ within noise |
M13 Setters_Suppression_Scope |
101.0 | -6.5% 95% CI [-12.8, -0.2] | 26.7 | 0.0% 95% CI [0.0, 0.0] | ≈ within noise |
M14 Dsl_Rebuild_Cascade |
1498121.2 | -13.9% 95% CI [-14.9, -13.0] | 2231828.9 | 0.0% 95% CI [0.0, 0.0] | ≈ within noise |
C207 ChangeHandler_DpRead_Coalesce |
1183.0 | +2.3% 95% CI [-1.3, +5.8] | 0.6 | 0.0% 95% CI [0.0, 0.0] | ≈ within noise |
OAlloc Optional_Element_Alloc |
213.8 | +1.4% 95% CI [-2.3, +5.1] | 528.0 | 0.0% 95% CI [0.0, 0.0] | ≈ within noise |
OUpdate Optional_Reconciler_Update |
12208.3 | -1.6% 95% CI [-2.7, -0.4] | 2772.3 | 0.0% 95% CI [0.0, 0.0] | ≈ within noise |
Cross-framework reference (same StocksGrid workload)
| Metric | vanilla WinUI3¹ | Rust windows-reactor² |
Reactor (this PR) |
|---|---|---|---|
| Renders/sec ↑ | 3.45 | 4.85 | 2.61 |
| Avg Reconcile (ms) ↓ | n/a | 18.8 | 124.1 |
| Avg Diff (ms) ↓ | n/a | 16.2 | 113.4 |
| Avg Memory (MB) ↓ | 262.7 | 195.7 | 283.7 |
↑ higher is better · ↓ lower is better. Within noise = the 95% confidence interval of the paired Δ includes 0 (no change resolvable at this sample size); ✅ improvement /
Allocation metrics (alloc bytes/render, Gen0 GC) are the sensitive signal for allocation-reduction work, where the mean-ms / memory figures are largely flat. They read n/a for a harness built from a revision that predates them (rebase the PR onto main to populate them).
Reconciler micro-benchmarks run PerfBench.ControlModel --variant Reactor (M1–M13) as a headless loop bracketed by per-thread alloc + GC counters — ns-resolution and free of WinUI render / working-set dilution, so they resolve Core/Reconciler allocation deltas the macro StocksGrid workload cannot. main and PR each link their own src/Reactor build and are rep-interleaved (a fresh alternated process per rep); Δ is the paired 95% CI over per-rep means. The Status column tracks allocated bytes/op (deterministic for identical code); ns/op is informational — its paired CI is now unbiased but the flag stays dormant pending a real-CI identical-binary band calibration.
¹ vanilla WinUI3 = StressPerf.Direct (imperative; no virtual-DOM, so it has no reconcile/diff phase — those cells read n/a). Measured live on this runner.
² Rust = test_reactor_perf from microsoft/windows-rs — a port of this harness (same StocksGrid, same --percent/--duration CLI). Built from source and measured live on this runner.
Absolute numbers are runner-dependent — trust the Δ vs main, not the absolute values. Memory (working set) is the noisiest metric.
Runner: CPU: AMD EPYC 7763 64-Core Processor · 4 logical cores · 16 GB RAM · runner: GitHub Actions 1043537152.
Generated by .github/workflows/perf-compare.yml · PR e35b8b9 vs main ecff5e5 · 2026-07-01T00:35:16Z · run log.
|
/perf |
Re-validation of #666 (the "honest no-op") — verdict: the no-op holdsI re-applied #666's changes onto current The second run was deliberate: run 1 appeared to show a clear DataGrid win that contradicted the no-op call, and the DataGrid re-render is async / dispatcher-debounced (the harness itself flags those timing rows as "noisier"). A finding that contradicts the prior verdict needs to reproduce. Two-run comparison
Every DataGrid CI that excluded zero in run 1 crosses zero in run 2. The point estimates stay directionally favorable (they never favor Verdict
Recommendation: keep #666 closed. The evidence does not support overturning the no-op. If DataGrid delegate/alloc coalescing is worth revisiting later, the harness's DataGrid dispatcher-debounce noise should be reduced first so a ~2–4% effect can actually resolve run-over-run. This draft PR (#769) was a measurement vehicle only — not intended to merge. Full per-run tables are in the sticky |
|
Closing — measurement complete. Two interleaved CI /perf\ runs confirm the #666 'honest no-op' verdict holds (see the verdict comment above). Branch \�zchohfi-perf-coalesce-com-interop-reads\ is kept for reference; not deleting it. |
Why this PR exists
PR #666 implemented issue #654 ("coalesce COM-interop reads + allocations in the
reconcile path") and was closed as an "honest no-op" — the optimizations are
real and behavior-preserving, but their effect measured below
/perfresolutionon the available workloads (no win, no regression), and the earlier skip-floor
rpsregression was judged a macro-rps false positive.This PR re-applies #666's changes onto current
mainpurely toindependently re-measure via the authoritative CI
/perfworkflow andconfirm (or refute) that no-op verdict on today's baseline. It is a measurement
vehicle and is not intended to merge as-is.
What's here
azchohfi-reconciler-interop-perf(PR perf: coalesce COM-interop reads + allocations in reconcile path #666) onto currentmain.Reconciler.csApplyResourceOverrides, resolvedin favor of main's perf/correctness: holistic audit of ApplyResourceOverrides + dirty-ancestor side-effects across the skip fast-path (positional + keyed) and the oldOverrides==null removal gate #675 removal-guard fix (drop the
oldOverrides is not nullgate, which leaked stale managed keys for pooled/Mount-path controls) while keeping
the perf-docs(020): refine async resources spec after design review #26 deferred-removal loop body. The other 7 files auto-merged.
Local validation (ARM64 dev box, x64 build)
Microsoft.UI.Reactor.dllcompiles clean (0 C# errors).dotnet test tests/Reactor.Tests: 9999 passed, 0 failed (incl. the 21 newReconcilerInteropPerfTests— rerender-cache,CurrentValueEquals, scanner parity).tests/Reactor.SelfTests(live WinUI): 636 passed; the lone batch failure was ashared-300s-budget timeout on
AsyncResource.Framerate.DataGridScroll, which passesin isolation — an environmental timing flake, not a reconcile regression.
Result — the no-op holds ✅
Ran CI
/perftwice (interleaved paired-Δ, 12 reps each). Full write-up + two-runtable in this comment.
within noise on every macro workload, across both runs.
rps −6.6%regression is a confirmed false positive (−0.4%, then 0.0%).(−2.4% bytes/render, tight CI) the author already acknowledged.
all CIs excluding zero) that did not reproduce in the confirmatory run (every CI
crossed back over zero). Directionally favorable, but below reproducible-significance —
the confirmatory run avoided reporting a run-1 false positive.
Recommendation: keep #666 closed. The evidence doesn't support overturning the no-op.
Closes nothing. Refs #654, #666.