You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Don't let a reused or memoized panel child swallow a component's own update - #1308
A component that sets its own state never re-rendered when the element holding it was the same instance on every render: a reused element (an app that re-emits one DockManager), an explicitly memoized wrapper such as UseMemo(() => Border(Counter()), []), a reused children array, or a Memo(key, …) used as a plain panel child. The child-skip arms in ChildReconciler (positional UpdateCommonChild, keyed prefix, keyed suffix) skip any CanSkipUpdate-equal child without consulting the dirty-ancestor path, so the root-down pass stopped above the component. Its node stayed self-triggered and the new state never rendered; a reused DockManager never drained a queued model.PinToSide or Float. UpdateCommonChild documented this as a residual edge. It reproduces in every shape.
The fix:
Skip arms decline only for dirty children.PopulateDirtyAncestorPath now also records, for each control on the path, which child the path continues through. ChildReconciler.Reconcile resolves a container's dirty children once (Reconciler.ResolveDirtyChildIndices), using one IndexOf per dirty child. The three skip arms then decline exactly those indices: an integer compare for one dirty child, a binary search for several. A declined child goes through Update, whose existing IsOnDirtyAncestorPath gate continues the descent.
The hot skip floor is unchanged. When nothing in the pass self-triggered, resolution costs one field check and no child's control is read. When a component elsewhere self-triggered, a container off the path pays one hash lookup. No case reads a control per skipped child. The per-child probe is only a fallback for a parent that isn't the collection's owner, such as a third-party Panel<> descriptor whose GetCollection returns an inner panel. Every in-repo Panel<> uses c => c.Children.
The PR-C structural fast-path gate uses the resolved indices. Its comment called that gate "behaviorally redundant". It is now load-bearing, because the full walk declines for dirty cells and the fast path would skip them wholesale.
Memo(key, …) as a plain child. The same-key arm in Reconciler.Update returned null without descending. When the control is on the dirty path, it now re-runs the factory, which is pure by contract, and reconciles that output against itself, so only the dirty path descends. Same-key passes that don't involve the subtree remain no-ops, with no factory call; a fixture pins this. The XML docs and the collections guide are updated.
Docs. The residual-edge comment in UpdateCommonChild and the fast-path gate comment are rewritten. The reconciliation guide is updated (template plus compiled page, since the child-diff snippet changed). There is a CHANGELOG entry under Fixed.
Linked issue / spec
No issue was filed: this PR is the report. It extends the dirty-ancestor path added in #377. Existing comments call it "#681's dirty-ancestor path", but #681 is an unrelated Yoga issue, so the new comments don't repeat that label.
Test plan
The regression fixtures are in tests/Reactor.AppTests.Host/SelfTest/Fixtures/SelfTriggeredReusedChildFixtures.cs. They are selftests because the path needs live component wrappers and the visual-tree walk that builds the dirty path, and headless code can't construct either. In each fixture the component's own button changes state, so only the self-triggered path can deliver the update:
Positional: a reused instance, with an in-fixture positive control (a sibling counter rebuilt every render, which updates on main too). Also a memoized Border(Counter()), a nested reused tree, and a UseMemoCellsByIndex hinted range.
Keyed prefix and keyed suffix.
A reused DockManager as a panel child, where model.PinToSide and model.Hide must drain.
A Memo(key, …) panel child. An unrelated pass must not re-run the factory or re-render the component.
A negative case: a reused sibling that is not on the dirty path stays skipped.
DirtyChildrenFoundByIndex captures ResolveDirtyChildIndices mid-pass. It returns At(1) for one dirty child and AtAll(1,3) for two in the same pass, which proves the IndexOf path runs rather than the per-child probe.
InnerPanelCollectionUsesFallback registers a descriptor whose Panel<> collection is an inner StackPanel, so the dirty child can't be found by index. A reused counter must still update, and the mid-pass capture asserts ProbeEachChild.
Headless tests in tests/Reactor.Tests/DirtyChildIndicesTests.cs: the index modes never read a control, and AtAll sorts its input for the binary search. With nothing self-triggered, neither resolution nor the positional and keyed skip floor reads a control or calls IndexOf.
Results, with exact commands:
Baseline:git stash of src and docs, so origin/main 885a5d8d0 product code with the new fixtures. Reactor.AppTests.Host.exe --self-test --filter "SelfTrigReuse" → 36 failures across 9 fixtures (the two capture fixtures need the new API). The positive control passed. The DockManager fixture reported pending=1, then pending=2.
Fix: the same command on the merge head 2da96c364 → 11 fixtures, 0 failures.
Revert proofs by in-place mutation. For each, the edit was confirmed in git diff, the Reactor.dll rebuild was confirmed by timestamp, and the tree was restored until git status --porcelain was empty. The first four ran before the fallback fixture existed.
Both halves off → 40 failures, all 10 fixtures red.
Only the ChildReconciler half off → 34 failures; Memo(key, …) stays green.
Only the Memo(key, …) half off → exactly its 6 checks fail.
Dropping the second dirty child of a shared parent → exactly the two two-sibling checks fail (resolved=At(1), rendersB=1).
dotnet test tests/Reactor.SelfTests --no-build -p:Platform=x64 → 1,711 total: 1,709 passed and 1 skipped (the deliberate SelfTestVerdict_OnlySkips_PositiveControl). The 1 failure, WindowLevel_RuntimeFlip_Topmost, is open flake [Flaky] WindowLevel_RuntimeFlip_Topmost fails intermittently in the full selftest run #927: a race on the native WS_EX_TOPMOST style bit that fails in about a third of full runs on clean main and passes in isolation. It was also the only failure before the merge, and it passed in isolation on both builds.
dotnet restore Reactor.slnx, then dotnet build Reactor.slnx --no-restore -c Release -p:CI=true → succeeded with 0 errors. The only warnings are 2 WIN2D0001 MSBuild warnings from AnyCPU Win2D projects this PR doesn't touch.
mur docs compile --topic collections and --topic reconciliation → only the edited paragraphs and the changed child-diff snippet moved.
The unit, selftest and Release-build results above are from the merge head 2da96c364. They were first run on 00ebf52f8, with the same single selftest failure.
CI: on 5c9dc87a8, the last head before the merge, every check passed (44 passed, 2 skipped by design). On the merge head 2da96c364, attempt 1 had 42 passes and two failures, both already-tracked flakes:
Neither fixture can reach this PR's code. Both mount a root render function with ctx.UseState, and the chart isn't .Interactive(), so there is no component node to self-trigger. The new code then stops at its first field check, and the Memo(key, …) arm never matches. The identical code diff passed both shards on 5c9dc87a8, and both fixtures passed in my local full run of the merged tree. After that analysis I re-ran the two failed jobs once, and both passed: the head is now 44 passed and 2 skipped. Earlier, on f6875a148, the only failure was AOT Asym_Removed, open flake #1037.
Perf
Local run of Run-PerfBenchmark.ps1 -BaselineRoot <main worktree> -Percent 50 -Duration 10 -Reps 4 -Warmup 1: main and this branch interleaved on one i9-14900K, x64 Release. The machine is shared, so it is noisy, and absolute renders/sec are low here (vanilla WinUI3 managed only 4.81); trust the deltas. Every metric is within noise: every 95% CI includes 0.
Leg
Metric
main
PR
Δ (95% CI)
StocksGrid 50%
Renders/sec ↑
4.99
5.10
+4.2% [-7.2, +15.7]
Avg Reconcile (ms) ↓
32.9
31.8
-4.4% [-19.1, +10.2]
Avg Diff (ms) ↓
28.9
28.3
-4.1% [-18.5, +10.3]
Avg Memory (MB) ↓
279.4
277.2
-0.5% [-1.3, +0.3]
Alloc bytes/render ↓
4,927,500
4,817,831
-1.7% [-4.3, +1.0]
Skip floor (--percent 0)
Renders/sec ↑
14.27
14.29
-0.3% [-2.4, +1.8]
Avg Reconcile (ms) ↓
10.1
10.3
+3.6% [-8.9, +16.1]
Avg Diff (ms) ↓
9.2
9.5
+3.8% [-8.5, +16.2]
Keyed list
Renders/sec ↑
14.62
14.87
+1.8% [-1.6, +5.2]
Avg Reconcile (ms) ↓
6.0
6.2
+7.4% [-18.1, +32.9]
Alloc bytes/render ↓
172,753
172,652
-0.1% [-0.2, 0.0]
PerfBench.ControlModel
B/op
0.0% on 15/17 benches, all within noise
CI /perf (sticky comment; run 36908028150): 12 paired runs per side after 2 warmups, windows-latest x64, head 93628b4fd. That is the last product change before the binary search, which only affects passes with two or more dirty siblings in one panel, and no perf leg has those. No regression on any leg.
Leg
Metric
main
PR
Δ (95% CI)
Status
StocksGrid 50%
Renders/sec ↑
2.79
2.85
-0.1% [-4.0, +3.8]
≈ noise
Avg Reconcile (ms) ↓
123.5
123.1
-1.3% [-6.3, +3.7]
≈ noise
Avg Diff (ms) ↓
111.6
111.2
-0.9% [-5.4, +3.6]
≈ noise
Avg Memory (MB) ↓
284.9
284.8
-0.2% [-0.7, +0.4]
≈ noise
Alloc bytes/render ↓
5,004,768
4,972,837
-1.0% [-2.2, +0.2]
≈ noise
Skip floor (--percent 0)
Renders/sec ↑
16.22
15.87
+0.2% [-5.6, +5.9]
≈ noise
Avg Reconcile (ms) ↓
36.6
37.2
+1.9% [-3.0, +6.8]
≈ noise
Avg Diff (ms) ↓
34.1
35.1
+2.1% [-3.1, +7.3]
≈ noise
Keyed list
Renders/sec ↑
20.71
21.34
+3.3% [+0.8, +5.9]
✅ flagged
Avg Reconcile (ms) ↓
15.7
15.2
-2.1% [-4.4, +0.2]
≈ noise
Alloc bytes/render ↓
172,914
172,340
-0.4% [-0.7, -0.1]
✅ flagged
Flex/Yoga
Renders/sec ↑
1.24
1.24
+0.5% [-4.2, +5.2]
≈ noise
DataGrid
Renders/sec ↑
4.67
4.74
+1.1% [-2.2, +4.3]
≈ noise
Avg Reconcile (ms) ↓
105.4
103.6
-0.9% [-4.3, +2.5]
≈ noise
Alloc bytes/render ↓
13,812,260
13,775,729
-0.2% [-0.7, +0.2]
≈ noise
PerfBench.ControlModel (17 benches)
B/op
exactly 0.0% on 12; all rows ≈ noise
≈ noise
How to read these:
The skip-floor leg isolates the per-tick child skip walk this PR touches. The StocksGrid root is not a component node, so those passes have no dirty path and the new code is a single field check per panel.
The DataGrid leg is the one that exercises the new dirty-pass code. DataGridComponent re-renders itself through UseReducer, so every pass has a populated dirty path and resolves dirty indices on the DataGrid's ancestor panels. It is within noise.
I don't attribute the flagged keyed-list gains to this change: nothing in it speeds up the keyed arm. Treat them as noise.
The one micro-bench row with a CI above 0 is M7 Update_NoChange B/op +9.2% [+2.0, +16.5]; it stays under the ±3% flag band. Its timed loop runs no changed code: UpdateChild(e, e, control) on reference-equal leaves returns at Update's untouched element-level skip. Its 370 B/op is mostly the amortized one-time mount of 1000 TextBlocks, and it read +5.5% [-12.1, +23.2] in the local run.
Risk / breaking changes
No public API change.IChildCollection is internal; its new IndexOf has a default implementation, and every other new member is internal.
Behavior. A component inside a reused or memoized child now re-renders on its own state change; before, that update was silently dropped. A same-key Memo(key, …) re-runs its factory only on passes where a component inside it updated itself. That is safe under the factory's purity contract: the output is reconciled against itself, so nothing off the dirty path is written. Passes that don't involve the subtree still don't call the factory.
Perf-sensitive path: the child skip floor. When nothing self-triggered, each container reconcile pays one field check. When something did, each container on the path pays one IndexOf per dirty child.
Pre-existing and unchanged: a positional type-mismatch replacement under an exit transition re-inserts the outgoing control mid-loop, which shifts the indices of later children. That already affects children.Get(i) for every later child; the dirty indices share the same assumption.
…update
A component that updates its own state is reached by a pass that starts at the
root. The child-skip arms in ChildReconciler (positional UpdateCommonChild and
the keyed prefix/suffix loops) skipped any child for which
Element.CanSkipUpdate held, and a reference-equal child always does: a reused
element instance (an app re-emitting one DockManager), an explicitly memoized
wrapper such as UseMemo(() => Border(Counter()), []), or a reused children
array. Those arms never consulted the dirty-ancestor path, so the descent
stopped at the reused child and the component's new state never rendered.
Memo(key, ...) used as a plain panel child had the same hole one layer down:
its same-key update arm returned without descending.
The skip arms now decline for exactly the children that lead to a
self-triggered component. The dirty-ancestor walk also records which child
each path control descends through, and ChildReconciler resolves a panel's
dirty children once per reconcile with one IndexOf each, so the skip floor
stays free of a per-child COM read: membership is an integer compare, and
with nothing self-triggered in the pass the resolution is a single field
check. A same-key Memo(key, ...) on the dirty path re-runs its (pure) factory
and walks the output against itself to reach the component.
Selftest fixtures cover the positional path (reused instance, memoized wrapper,
nested reused tree, hinted range), the keyed prefix and suffix arms, a reused
DockManager whose model queue never drained, Memo(key, ...), a reused sibling
that must stay skipped, and the index resolution itself; headless tests pin
that the no-dirty-path skip floor reads no control.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Artifact sizes for 2da96c3 vs the base branch (cdb5d14).
Packages (compressed .nupkg)
Artifact
base
PR
Δ
Microsoft.UI.Reactor.nupkg
1.75 MB
1.75 MB
+2.83 KB (+0.16%)
⚠️
Microsoft.UI.Reactor.Advanced.nupkg
491.8 KB
491.8 KB
+14 B (0.00%)
≈
Microsoft.UI.Reactor.Devtools.nupkg
287.9 KB
287.9 KB
+14 B (0.00%)
≈
Assemblies in Microsoft.UI.Reactor
Artifact
base
PR
Δ
Reactor.Analyzers.dll
373.0 KB
373.0 KB
+0 B (0.00%)
≈
Reactor.dll
2.48 MB
2.48 MB
+2.00 KB (+0.08%)
⚠️
Reactor.Localization.Generator.dll
16.0 KB
16.0 KB
+0 B (0.00%)
≈
Reactor.Wrappers.Abstractions.dll
10.5 KB
10.5 KB
+0 B (0.00%)
≈
Reactor.Wrappers.Generator.dll
99.5 KB
99.5 KB
+0 B (0.00%)
≈
Assemblies in Microsoft.UI.Reactor.Advanced
Artifact
base
PR
Δ
Reactor.Advanced.dll
1023.5 KB
1023.5 KB
+0 B (0.00%)
≈
Assemblies in Microsoft.UI.Reactor.Devtools
Artifact
base
PR
Δ
Microsoft.UI.Reactor.Devtools.dll
788.5 KB
788.5 KB
+0 B (0.00%)
≈
✅ smaller / ⚠️ larger / ≈ within noise. Sizes come from a Release dotnet pack on the CI runner: packages are the compressed .nupkg download size, assemblies the uncompressed DLL inside it. workflow run.
Coverage for 2da96c3 vs the base branch (19f6c50) — unit + selftest merged.
Metric
base
PR
Δ
Line
86.17%
86.15%
-0.02 pp
≈
Branch
77.40% (966/1248)
77.40% (966/1248)
0.00 pp
≈
No coverage change beyond the noise floor. ✅
✅ higher / ⚠️ lower / ≈ within noise. Δ is in percentage points; coverage is unit + selftest merged (Debug x64) on the CI runner. Cobertura reports attached to the workflow run as artifacts.
A descriptor whose Panel<> collection belongs to an inner panel hands the child reconciler a parent that does not own the collection, so the dirty child cannot be found by index and each skip-eligible child is tested against the dirty path instead. The new selftest mounts that shape with a reused self-triggered counter, asserts the counter updates, and captures the resolution mid-pass to prove the fallback (not the index path) ran. Disabling the fallback fails exactly this fixture.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use binary search for dirty child index membership
src/Reactor/Core/ChildReconciler.cs:1050
Contains runs once for every skip-eligible child, so linearly scanning _indices makes a pass with n reused children and d dirty siblings perform O(n×d) managed comparisons. Batched sibling updates are supported (the new fixture sets two before one render), and ResolveDirtyChildIndices already sorts this array; use binary search so membership is O(log d).
Contains runs once per skip-eligible child, so a linear scan of several dirty indices cost O(children x dirty). AtAll now sorts its indices and Contains binary-searches them; the sort moved from the resolver into AtAll so the struct owns the invariant it relies on.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
Copilot review overview
🟢 Approval recommended
The reconciliation paths, fallback behavior, performance floor, documentation, and regression coverage are internally consistent with no unresolved defects found.
Workload:StressPerf.ReactorOptimized StocksGrid · --percent 50 --duration 10 · x64 Release · median of 12 paired runs (2 warmup dropped); Δ is the mean change with a 95% CI · PR head and main built and run interleaved on the same runner.
Regression vs main baseline
Metric
main (baseline)
This PR
Δ (95% CI)
Status
Renders/sec ↑
2.79
2.85
-0.1% 95% CI [-4.0, +3.8]
≈ within noise
Avg Reconcile (ms) ↓
123.5
123.1
-1.3% 95% CI [-6.3, +3.7]
≈ within noise
Avg Diff (ms) ↓
111.6
111.2
-0.9% 95% CI [-5.4, +3.6]
≈ within noise
Avg Memory (MB) ↓
284.9
284.8
-0.2% 95% CI [-0.7, +0.4]
≈ 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.
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.
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' OnRenderComplete phase hook, in FlexPanel.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.24
1.24
+0.5% 95% CI [-4.2, +5.2]
≈ within noise
Avg Reconcile (ms) ↓
162.4
163.9
+0.1% 95% CI [-2.4, +2.5]
≈ within noise
Avg Diff (ms) ↓
142.5
145.2
+0.9% 95% CI [-1.6, +3.5]
≈ within noise
Avg Memory (MB) ↓
246.2
246.3
-0.1% 95% CI [-1.3, +1.0]
≈ within noise
Allocation (flex) — lower is better
Metric
main (baseline)
This PR
Δ (95% CI)
Status
Alloc bytes/render ↓
8523412
8510950
+0.3% 95% CI [-0.3, +0.9]
≈ within noise
Gen0 GC / 1k renders ↓
461.54
461.54
-1.6% 95% CI [-4.5, +1.4]
≈ within noise
DataGrid control workload (StressPerf.DataGrid, --percent 50)
A separate macro workload: the real DataGrid control (DataGridComponent) over a 30-column × 200-rowIObservableDataSource 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 → coalesced forceRender + 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.67
4.74
+1.1% 95% CI [-2.2, +4.3]
≈ within noise
Avg Reconcile (ms) ↓
105.4
103.6
-0.9% 95% CI [-4.3, +2.5]
≈ within noise
Avg Diff (ms) ↓
105.3
103.5
-0.9% 95% CI [-4.3, +2.5]
≈ within noise
Avg Memory (MB) ↓
274.5
274.7
-0.2% 95% CI [-0.9, +0.6]
≈ within noise
Allocation (datagrid) — lower is better
Metric
main (baseline)
This PR
Δ (95% CI)
Status
Alloc bytes/render ↓
13812260
13775729
-0.2% 95% CI [-0.7, +0.2]
≈ within noise
Gen0 GC / 1k renders ↓
166.67
164.97
-0.2% 95% CI [-3.6, +3.2]
≈ within noise
Row memoization (opt-in) — same-build Baseline vs Memo
A separate single-build micro-bench (PerfBench.RowMemo, PR head only) that isolates the opt-in keyed row-memoization win from #327: a realistic 9-node variable-height row recycled 1,000,000 times through the real ElementFactory.BuildOrCache realize path — once withoutMemo (Baseline) and once withMemo(i, () => row) (Memo). The StocksGrid /perf legs can't show this (StocksGrid never opts into the API, so they read within-noise) and main lacks the Memo API entirely, so this leg is built + run from the PR head only, best-effort. Both arms share one build, so the two columns are an apples-to-apples A/B with no cross-tree drift; absolute ns is runner-dependent, so trust the Win ratios and the rebuilds→0 / CanSkipUpdate facts.
Metric
Baseline
Memo
Win
ns/recycle ↓
708.0
78.7
9.0× faster
bytes/recycle ↓
4,704
176
26.7× less
factory rebuilds (per 1,000,000 recycles) ↓
1,000,000
0
eliminated
Why the real win is bigger than the table. On a recycle that re-asks a still-cached key, Memo returns the same Element instance, so ReferenceEquals holds and Element.CanSkipUpdate is true — the reconciler returns at the row root and skips the entire 9-node per-row descent and the downstream WinUI control-patch. That stacked reconcile + control-patch saving is not captured by the headless ns/bytes figures above (which time only BuildOrCache). Baseline hands the reconciler a fresh-but-equal tree every recycle (sameInstance=false, CanSkipUpdate=false), forcing the full walk.
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.
↑ 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 / ⚠️ regression require the CI to exclude 0. 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 9V74 80-Core Processor · 4 logical cores · 16 GB RAM · runner: GitHub Actions 1064440375. Generated by .github/workflows/perf-compare.yml · PR 93628b4 vs main 885a5d8 · 2026-10-01T19:29:31Z · run log.
Resolves a CHANGELOG.md conflict: #1309's Devtools entry and this branch's entry were both added at the same place under Fixed. Both are kept, with the landed entry first.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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
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.
Summary
A component that sets its own state never re-rendered when the element holding it was the same instance on every render: a reused element (an app that re-emits one
DockManager), an explicitly memoized wrapper such asUseMemo(() => Border(Counter()), []), a reused children array, or aMemo(key, …)used as a plain panel child. The child-skip arms inChildReconciler(positionalUpdateCommonChild, keyed prefix, keyed suffix) skip anyCanSkipUpdate-equal child without consulting the dirty-ancestor path, so the root-down pass stopped above the component. Its node stayed self-triggered and the new state never rendered; a reusedDockManagernever drained a queuedmodel.PinToSideorFloat.UpdateCommonChilddocumented this as a residual edge. It reproduces in every shape.The fix:
PopulateDirtyAncestorPathnow also records, for each control on the path, which child the path continues through.ChildReconciler.Reconcileresolves a container's dirty children once (Reconciler.ResolveDirtyChildIndices), using oneIndexOfper dirty child. The three skip arms then decline exactly those indices: an integer compare for one dirty child, a binary search for several. A declined child goes throughUpdate, whose existingIsOnDirtyAncestorPathgate continues the descent.Panel<>descriptor whoseGetCollectionreturns an inner panel. Every in-repoPanel<>usesc => c.Children.Memo(key, …)as a plain child. The same-key arm inReconciler.Updatereturnednullwithout descending. When the control is on the dirty path, it now re-runs the factory, which is pure by contract, and reconciles that output against itself, so only the dirty path descends. Same-key passes that don't involve the subtree remain no-ops, with no factory call; a fixture pins this. The XML docs and thecollectionsguide are updated.UpdateCommonChildand the fast-path gate comment are rewritten. The reconciliation guide is updated (template plus compiled page, since thechild-diffsnippet changed). There is a CHANGELOG entry under Fixed.Linked issue / spec
No issue was filed: this PR is the report. It extends the dirty-ancestor path added in #377. Existing comments call it "#681's dirty-ancestor path", but #681 is an unrelated Yoga issue, so the new comments don't repeat that label.
Test plan
The regression fixtures are in
tests/Reactor.AppTests.Host/SelfTest/Fixtures/SelfTriggeredReusedChildFixtures.cs. They are selftests because the path needs live component wrappers and the visual-tree walk that builds the dirty path, and headless code can't construct either. In each fixture the component's own button changes state, so only the self-triggered path can deliver the update:maintoo). Also a memoizedBorder(Counter()), a nested reused tree, and aUseMemoCellsByIndexhinted range.DockManageras a panel child, wheremodel.PinToSideandmodel.Hidemust drain.Memo(key, …)panel child. An unrelated pass must not re-run the factory or re-render the component.DirtyChildrenFoundByIndexcapturesResolveDirtyChildIndicesmid-pass. It returnsAt(1)for one dirty child andAtAll(1,3)for two in the same pass, which proves theIndexOfpath runs rather than the per-child probe.InnerPanelCollectionUsesFallbackregisters a descriptor whosePanel<>collection is an innerStackPanel, so the dirty child can't be found by index. A reused counter must still update, and the mid-pass capture assertsProbeEachChild.tests/Reactor.Tests/DirtyChildIndicesTests.cs: the index modes never read a control, andAtAllsorts its input for the binary search. With nothing self-triggered, neither resolution nor the positional and keyed skip floor reads a control or callsIndexOf.Results, with exact commands:
git stashofsrcanddocs, so origin/main885a5d8d0product code with the new fixtures.Reactor.AppTests.Host.exe --self-test --filter "SelfTrigReuse"→ 36 failures across 9 fixtures (the two capture fixtures need the new API). The positive control passed. The DockManager fixture reportedpending=1, thenpending=2.2da96c364→ 11 fixtures, 0 failures.git diff, theReactor.dllrebuild was confirmed by timestamp, and the tree was restored untilgit status --porcelainwas empty. The first four ran before the fallback fixture existed.ChildReconcilerhalf off → 34 failures;Memo(key, …)stays green.Memo(key, …)half off → exactly its 6 checks fail.resolved=At(1),rendersB=1).InnerPanelCollectionUsesFallbackfails (5 checks,renders=1); everything else stays green.dotnet test tests/Reactor.Tests --no-build -p:Platform=x64→ Passed: 14,401 total, 0 failed, 64 skipped.dotnet test tests/Reactor.SelfTests --no-build -p:Platform=x64→ 1,711 total: 1,709 passed and 1 skipped (the deliberateSelfTestVerdict_OnlySkips_PositiveControl). The 1 failure,WindowLevel_RuntimeFlip_Topmost, is open flake [Flaky] WindowLevel_RuntimeFlip_Topmost fails intermittently in the full selftest run #927: a race on the nativeWS_EX_TOPMOSTstyle bit that fails in about a third of full runs on cleanmainand passes in isolation. It was also the only failure before the merge, and it passed in isolation on both builds.dotnet restore Reactor.slnx, thendotnet build Reactor.slnx --no-restore -c Release -p:CI=true→ succeeded with 0 errors. The only warnings are 2WIN2D0001MSBuild warnings from AnyCPU Win2D projects this PR doesn't touch.mur docs compile --topic collectionsand--topic reconciliation→ only the edited paragraphs and the changedchild-diffsnippet moved.main. Merging them in (2da96c364) conflicted only inCHANGELOG.md, where both sides added an entry at the same spot under Fixed; both entries are kept. Tag controls mounted through Reconciler.RegisterType #1301'sReconciler.cschanges (registered-type tagging, the unmount guard,.Refclearing) merged automatically and don't touch the dirty path, the child-skip arms orMemo(key, …). The merge leaves the PR's code, docs and test diff againstmainunchanged (samegit patch-id --stable). On the merged tree, theSelfTrigReuse(11),RegisterType(15),NativeDocking(83),StructuralSkip(3) andIssue811(7) fixture sets all pass.git merge-tree --write-treewith the still-open Keep an AutoSuggestBox alive until its deferred TextChanged has fired #1302 (9e31a1292) and Close a docking host's floating windows whichever DockManager opened them #1305 (803aaff55) is clean. Close a docking host's floating windows whichever DockManager opened them #1305 re-keysDockHostModelBridgeby host identity but keepsGet(DockManager), so the DockManager fixture stays valid after it lands.The unit, selftest and Release-build results above are from the merge head
2da96c364. They were first run on00ebf52f8, with the same single selftest failure.CI: on
5c9dc87a8, the last head before the merge, every check passed (44 passed, 2 skipped by design). On the merge head2da96c364, attempt 1 had 42 passes and two failures, both already-tracked flakes:0xC0000005whileConnectedAnimation_OrphanOnlyPassDoesNotCrashwas running, which is [Flaky] AOT Selftests: process dies mid-run at fixture 481/1459 with no TAP trailer and nonot ok#1152 (an access violation with that fixture as the last one started, seen in 18+ CI jobs since 2026-09-18). Every later fixture in the shard is an inconclusive abort.Issue487_SV2ParkedAtBottomandIssue487_SV2ClampObservedfailed, which is [Bug] Issue487_SV2* fail deterministically on non-interactive sessions — InteractionTracker completes scrolls without moving #990's signature exactly.SV2HasScrollableHeightpassed, and then a plainScrollView.ScrollTodidn't move the offset on the non-interactive runner, before any reconcile ran.Neither fixture can reach this PR's code. Both mount a root render function with
ctx.UseState, and the chart isn't.Interactive(), so there is no component node to self-trigger. The new code then stops at its first field check, and theMemo(key, …)arm never matches. The identical code diff passed both shards on5c9dc87a8, and both fixtures passed in my local full run of the merged tree. After that analysis I re-ran the two failed jobs once, and both passed: the head is now 44 passed and 2 skipped. Earlier, onf6875a148, the only failure was AOTAsym_Removed, open flake #1037.Perf
Local run of
Run-PerfBenchmark.ps1 -BaselineRoot <main worktree> -Percent 50 -Duration 10 -Reps 4 -Warmup 1:mainand this branch interleaved on one i9-14900K, x64 Release. The machine is shared, so it is noisy, and absolute renders/sec are low here (vanilla WinUI3 managed only 4.81); trust the deltas. Every metric is within noise: every 95% CI includes 0.main--percent 0)PerfBench.ControlModelCI
/perf(sticky comment; run 36908028150): 12 paired runs per side after 2 warmups,windows-latestx64, head93628b4fd. That is the last product change before the binary search, which only affects passes with two or more dirty siblings in one panel, and no perf leg has those. No regression on any leg.main--percent 0)PerfBench.ControlModel(17 benches)How to read these:
DataGridComponentre-renders itself throughUseReducer, so every pass has a populated dirty path and resolves dirty indices on the DataGrid's ancestor panels. It is within noise.M7 Update_NoChangeB/op +9.2% [+2.0, +16.5]; it stays under the ±3% flag band. Its timed loop runs no changed code:UpdateChild(e, e, control)on reference-equal leaves returns atUpdate's untouched element-level skip. Its 370 B/op is mostly the amortized one-time mount of 1000 TextBlocks, and it read +5.5% [-12.1, +23.2] in the local run.Risk / breaking changes
IChildCollectionis internal; its newIndexOfhas a default implementation, and every other new member is internal.Memo(key, …)re-runs its factory only on passes where a component inside it updated itself. That is safe under the factory's purity contract: the output is reconciled against itself, so nothing off the dirty path is written. Passes that don't involve the subtree still don't call the factory.IndexOfper dirty child.children.Get(i)for every later child; the dirty indices share the same assumption.