Repository navigation
perf: eliminate per-diff allocations in ChildReconciler + KeyedListDiff - #657
Conversation
There was a problem hiding this comment.
Pull request overview
This PR targets a known perf hotspot in Reactor’s keyed child reconciliation + keyed list diff pipeline by eliminating per-diff allocations (via pooling) and restoring missing fast paths, while adding regression coverage to ensure diff correctness and buffer-reuse safety.
Changes:
- Add pooled/length-threaded buffer handling and new early fast paths in
KeyedListDiff(including moving the no-op check ahead of duplicate detection). - Optimize keyed reconciliation in
ChildReconciler(prefix/suffixCanSkipUpdateearly-exit, pooled LIS mask/buffers, pooled key→index maps, and cheaper filtering/key generation). - Add new unit tests covering pooling non-corruption scenarios and
ComputeLISIntomask semantics.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Reactor/Core/ChildReconciler.cs | Keyed reconcile fast paths + pooled LIS/dictionaries/arrays to reduce per-tick work/allocations. |
| src/Reactor/Core/Internal/KeyedListDiff.cs | ArrayPool-backed key materialization and reordered fast paths; pooled removal buffers and reduced scratch churn. |
| tests/Reactor.Tests/Internal/KeyedListDiffPoolingTests.cs | New regression suite for pooled keyed diff correctness and reuse safety. |
| tests/Reactor.Tests/ChildReconcilerLisIntoTests.cs | New tests validating ComputeLISInto mask behavior vs legacy set-based wrapper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Review follow-ups on #657 (keyed list-diff allocation work): - ChildReconciler.ReconcileKeyedMiddle: return the pooled matched and inLis bool[] buffers with clearArray:false instead of true (Copilot review). Both are value-typed (no reference pinning) and have their used range fully (re)initialized before any read - matched via the Array.Clear on rent, inLis via ComputeLISInto leading clear - so the full-array wipe on return was avoidable O(rented-capacity) work on the hot path. Matches how the int[] newToOld already returns. Reference-typed pooled buffers (string[]/ReactorRow[] in KeyedListDiff) still clear. - Tests (ChildReconcilerLisIntoTests): replace the circular oracle that compared ComputeLISInto against ComputeLIS (now a thin wrapper over it) with an independent brute-force LIS-length DP that honors the -1 unmapped sentinel, asserting the mask marks a valid strictly-increasing subsequence of maximal length. - Tests (ChildReconcilerKeyedSkipTests, new): cover the #30 keyed CanSkipUpdate fast path - an identical keyed list skips every row with no ops and no child-control access, across repeated stable frames. Co-authored-by: Copilot <[email protected]>
|
/perf |
Hot keyed list-diff path (grid steady state) allocated heavily and missed fast-paths even when keys were unchanged. Eliminate per-diff allocations and add the missing fast-path, preserving diff behavior exactly. ChildReconciler.cs: - Keyed prefix/suffix loops now take the Element.CanSkipUpdate early-exit that the positional path has, so stable keyed rows no longer re-diff every tick (#30); cache children.Count once instead of re-reading the COM IVector.get_Size per suffix iteration (#37). - Replace HashSet-returning ComputeLIS with allocation-free ComputeLISInto filling a pooled bool mask; pool tails/tailIndices/predecessors from ArrayPool (#31/#32). Keep a thin ComputeLIS(int[]) wrapper for tests. - Pool ReconcileKeyedMiddle's working arrays (ArrayPool) and the two key->index maps (re-entrancy-safe ThreadStatic dict pool); buffers cleared and returned on every exit (#33). - Filter: count-pass + single Element[] fill, no List+ToArray (#36). - GetKey: cache Type.Name via ConcurrentDictionary (#38). KeyedListDiff.cs: - Rent newKeys from ArrayPool<string>, threading explicit newCount (rented array may be larger); returned clearArray:true in a finally (#2). - Move the no-op (SequenceEqual) + empty/empty fast paths ABOVE the duplicate scan so the steady-state grid case never allocates/scans a dup set (#1). - Fold the churn-bailout decision into ApplyGeneral, computed from the same post-prefix/suffix scratch map the general walk builds (diff-range churn == full-range churn), removing the O(2n) null-marker pre-pass (#34). - Pool the doomed ReactorRow[] (ArrayPool, descending IComparer sort over [0,removes), cleared+returned) (#3). - Lazy-allocate movedRows only on an actual move under an ambient (#35). - In-place SyncLastKeysToSource instead of LastKeys Clear()+Add (#10). - HasDuplicates reuses state.Scratch (TryAdd) for 4+ keys instead of a fresh HashSet (#11); cached null-key diagnostic sample (#41). Tests: add pooling non-corruption coverage (rented-buffer-larger-than-count, interleaved independent states, randomized stress vs oracle with survivor identity, pooled doomed removes, churn with shared prefix+suffix, Scratch reuse for the dup scan) and ComputeLISInto bool-mask coverage. Full Reactor.Tests suite green (9693 passed); core lib Release build is warning-clean (AOT/trim). Closes #653 Co-authored-by: Copilot <[email protected]>
Review follow-ups on #657 (keyed list-diff allocation work): - ChildReconciler.ReconcileKeyedMiddle: return the pooled matched and inLis bool[] buffers with clearArray:false instead of true (Copilot review). Both are value-typed (no reference pinning) and have their used range fully (re)initialized before any read - matched via the Array.Clear on rent, inLis via ComputeLISInto leading clear - so the full-array wipe on return was avoidable O(rented-capacity) work on the hot path. Matches how the int[] newToOld already returns. Reference-typed pooled buffers (string[]/ReactorRow[] in KeyedListDiff) still clear. - Tests (ChildReconcilerLisIntoTests): replace the circular oracle that compared ComputeLISInto against ComputeLIS (now a thin wrapper over it) with an independent brute-force LIS-length DP that honors the -1 unmapped sentinel, asserting the mask marks a valid strictly-increasing subsequence of maximal length. - Tests (ChildReconcilerKeyedSkipTests, new): cover the #30 keyed CanSkipUpdate fast path - an identical keyed list skips every row with no ops and no child-control access, across repeated stable frames. Co-authored-by: Copilot <[email protected]>
83599a0 to
13679c9
Compare
|
/perf |
⚡ Reactor perf comparisonWorkload: Regression vs
|
| Metric | main (baseline) |
This PR | Δ (95% CI) | Status |
|---|---|---|---|---|
| Renders/sec ↑ | 2.75 | 2.78 | +1.4% 95% CI [-4.0, +6.8] | ≈ within noise |
| Avg Reconcile (ms) ↓ | 131.8 | 129.0 | -0.8% 95% CI [-2.7, +1.1] | ≈ within noise |
| Avg Diff (ms) ↓ | 113.5 | 112.3 | -0.7% 95% CI [-2.5, +1.1] | ≈ within noise |
| Avg Memory (MB) ↓ | 280.6 | 279.5 | -0.2% 95% CI [-0.7, +0.3] | ≈ 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.34 | 14.49 | -2.0% 95% CI [-6.9, +2.8] | ≈ within noise |
| Avg Reconcile (ms) ↓ | 26.1 | 27.4 | +3.5% 95% CI [-0.6, +7.6] | ≈ within noise |
| Avg Diff (ms) ↓ | 24.5 | 25.4 | +3.1% 95% CI [-1.2, +7.5] | ≈ within noise |
| Avg Memory (MB) ↓ | 268.7 | 267.6 | -0.3% 95% CI [-0.5, 0.0] | ✅ improvement |
Allocation (Reactor) — lower is better
| Metric | main (baseline) |
This PR | Δ (95% CI) | Status |
|---|---|---|---|---|
| Alloc bytes/render ↓ | 6129487 | 6136017 | +0.2% 95% CI [-0.9, +1.3] | ≈ within noise |
| Gen0 GC / 1k renders ↓ | 344.83 | 339.08 | +0.5% 95% CI [-4.4, +5.3] | ≈ 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 ↑ | 22.88 | 20.46 | -10.2% 95% CI [-11.3, -9.1] | |
| Avg Reconcile (ms) ↓ | 13.3 | 16.0 | +20.4% 95% CI [+19.2, +21.6] | |
| Avg Diff (ms) ↓ | 13.2 | 15.8 | +20.5% 95% CI [+19.2, +21.9] | |
| Avg Memory (MB) ↓ | 179.1 | 177.2 | -1.0% 95% CI [-1.5, -0.4] | ✅ improvement |
Allocation (keyed-list) — lower is better
| Metric | main (baseline) |
This PR | Δ (95% CI) | Status |
|---|---|---|---|---|
| Alloc bytes/render ↓ | 312945 | 216180 | -30.9% 95% CI [-31.0, -30.7] | ✅ improvement |
| Gen0 GC / 1k renders ↓ | 12.85 | 9.57 | -25.6% 95% CI [-26.5, -24.8] | ✅ improvement |
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 |
114832.4 | -0.3% 95% CI [-1.2, +0.6] | 1140.9 | 0.0% 95% CI [0.0, 0.0] | ≈ within noise |
M2 Mount_Leaf_OneCallback |
83664.8 | -0.7% 95% CI [-2.7, +1.3] | 3383.3 | 0.0% 95% CI [-0.1, 0.0] | ≈ within noise |
M3 Mount_Leaf_ThreeCallbacks |
171644.3 | -0.4% 95% CI [-3.4, +2.6] | 8181.4 | -0.9% 95% CI [-2.5, +0.6] | ≈ within noise |
M4 Dispatch_Switch_Cold |
83813.1 | +0.3% 95% CI [-0.4, +1.1] | 1768.1 | 0.0% 95% CI [0.0, 0.0] | ≈ within noise |
M5 Dispatch_Switch_Warm |
85268.4 | +0.4% 95% CI [-3.1, +3.9] | 1766.0 | +0.4% 95% CI [-0.4, +1.2] | ≈ within noise |
M6 Dispatch_ExternalType |
71551.8 | -0.2% 95% CI [-3.6, +3.2] | 987.6 | +0.7% 95% CI [-0.8, +2.2] | ≈ within noise |
M7 Update_NoChange |
43628.2 | +1.2% 95% CI [-1.6, +4.1] | 452.1 | +2.2% 95% CI [-4.6, +9.0] | ≈ within noise |
M8 Update_OneLeafChanged |
32659.0 | +0.8% 95% CI [-2.8, +4.5] | 536.0 | 0.0% 95% CI [0.0, 0.0] | ≈ within noise |
M9 Update_AllChanged |
2772140.2 | -0.1% 95% CI [-2.2, +2.1] | 184278.1 | 0.0% 95% CI [0.0, 0.0] | ≈ within noise |
M10 EventHandlerState_Alloc |
67587.3 | -1.6% 95% CI [-4.6, +1.3] | 3013.2 | +0.2% 95% CI [-0.3, +0.8] | ≈ within noise |
M11 ModifierEHS_Frequency |
35579.7 | -2.3% 95% CI [-4.7, 0.0] | 638.8 | 0.0% 95% CI [-0.1, +0.1] | ≈ within noise |
M12 Pool_Rent_HotPath |
92523.8 | -1.1% 95% CI [-2.3, 0.0] | 1099.9 | 0.0% 95% CI [0.0, 0.0] | ≈ within noise |
M13 Setters_Suppression_Scope |
129.2 | -0.5% 95% CI [-7.3, +6.2] | 26.7 | 0.0% 95% CI [0.0, 0.0] | ≈ within noise |
M14 Dsl_Rebuild_Cascade |
1575009.9 | 0.0% 95% CI [-1.9, +2.0] | 2231828.9 | 0.0% 95% CI [0.0, 0.0] | ≈ within noise |
C207 ChangeHandler_DpRead_Coalesce |
1228.8 | -0.8% 95% CI [-6.5, +5.0] | 0.6 | 0.0% 95% CI [0.0, 0.0] | ≈ within noise |
OAlloc Optional_Element_Alloc |
164.0 | -2.0% 95% CI [-8.6, +4.5] | 528.0 | 0.0% 95% CI [0.0, 0.0] | ≈ within noise |
OUpdate Optional_Reconciler_Update |
12173.6 | +1.0% 95% CI [-0.8, +2.9] | 2854.3 | -0.2% 95% CI [-0.8, +0.3] | ≈ within noise |
Cross-framework reference (same StocksGrid workload)
| Metric | vanilla WinUI3¹ | Rust windows-reactor² |
Reactor (this PR) |
|---|---|---|---|
| Renders/sec ↑ | 3.58 | 5.15 | 2.78 |
| Avg Reconcile (ms) ↓ | n/a | 21.1 | 129.0 |
| Avg Diff (ms) ↓ | n/a | 18.8 | 112.3 |
| Avg Memory (MB) ↓ | 262.4 | 197.9 | 279.5 |
↑ 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: Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz · 4 logical cores · 16 GB RAM · runner: GitHub Actions 1043006366.
Generated by .github/workflows/perf-compare.yml · PR e664f9f vs main e8572a0 · 2026-06-27T07:20:21Z · run log.
…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]>
|
/perf |
…tests The keyed-middle reconciliation in ChildReconciler patched surviving controls by their FINAL panel index while the panel was only partially rearranged, so on reorders a survivor was patched against the wrong control (C1, CRITICAL): e.g. rotation [a,b,c,d]->[b,c,d,a] rendered "c" at slot 0 and scrambled keyed identity (focus/animation/state landed on the wrong row). A related stale keyToIndex (only the moved key was rewritten) left shifted siblings mis-indexed after an insert/move (H1). Fix: extract the index logic into RunKeyedMiddleCore<TSink> behind a struct-generic IKeyedMiddleSink seam (devirtualized, AOT-clean) and replace the left-to-right loop with the canonical right-to-left LIS walk. Each item is positioned immediately before its already-placed right neighbour; LIS members stay put and only out-of-LIS movers relocate (minimal moves). Every survivor is patched at its CURRENT live position, resolved from a pooled oldRelToPanel int[] that is mutated in lock-step with every Insert/Move so it stays exact -- fixing C1 and H1 together. The production RealKeyedMiddleSink drives the identical Mount/Move/ UpdateChild/Unmount/Replace + ambient enter/move behaviour as before. oldRelToPanel replaces the second pooled key->index dict (one fewer rented dict per call). Tests: - ChildReconcilerKeyedMiddleCoreTests (new): a headless SimKeyedMiddleSink drives the SAME RunKeyedMiddleCore over identity cells (exact production parity, no live-WinUI selftest wall), with a 4-invariant oracle (length, prefix/suffix untouched, per-slot identity+content, every patch hits its claimed survivor) across rotation, full reverse, scramble, block-swap, inserts/removes/duplicates and prefix/suffix offsets. A faithful pre-fix reproduction proves the rotation regression test has teeth (the buggy walk corrupts content[0] and mis-patches; the real core is clean). - KeyedListDiffPoolingTests: two GC.GetAllocatedBytesForCurrentThread budgets guarding the #1/#2/#11 pooling -- no-op steady-state diff is 0 B/iter and a 128-key reorder is 72 B/diff; reverting the pooling (a new string[128] + a 128-entry HashSet per diff) fails them. Diff correctness preserved; pooled buffers returned on every exit. Co-authored-by: Copilot <[email protected]>
|
/perf |
Address Copilot re-review of e664f9f. KeyedListDiff: the no-op fast path runs above the duplicate scan (#1), so an UNCHANGED list that already holds duplicate keys -- the state a prior duplicate bailout leaves behind, since ReactorListState.Reset preserves the dups in Source/LastKeys but collapses ByKey to first occurrences -- would match LastKeys and return Empty, silently skipping the duplicate bailout/diagnostic and leaving the diff in an invalid duplicate state. Gate the fast path on `state.ByKey.Count == oldCount`: true exactly for the duplicate-free steady state (allocation-free path preserved), false when dups were collapsed (re-takes the bailout). The check is O(1) and short-circuits before the O(n) SequenceEqualOrdinal, so the common unique-key path pays nothing. No-op steady-state allocation stays 0 B/iter. Tests: - KeyedListDiffTests: new Apply_Unchanged_Duplicate_List_Re_Bails_Instead_ Of_NoOp_FastPath -- proves an unchanged duplicate list re-bails; verified to FAIL without the guard (takes the no-op path and returns Empty). - ChildReconcilerLisIntoTests: strengthen the LIS oracle to assert selected indices are never the unmapped -1 sentinel (a buggy impl could swap a real member for a -1 and still satisfy strictly-increasing + length). - KeyedListDiffPoolingTests: drop the unused `using System.Buffers;` (fully-qualify the one ArrayPool cref) flagged by the reviewer. Co-authored-by: Copilot <[email protected]>
Closes #653
What
Two things in the keyed list-diff path:
ReconcileKeyedMiddle(C1/H1, see below) surfaced during review, and adds the reorder-oracle coverage that was previously disabled.Scope is limited to
src/Reactor/Core/ChildReconciler.csandsrc/Reactor/Core/Internal/KeyedListDiff.cs(+ tests).Correctness fix — keyed-middle reorder identity (C1/H1)
children.Get(prefixLen + i)) while the panel was only partially rearranged, so on a reorder a survivor could be patched against the wrong control — e.g. rotation[a,b,c,d] → [b,c,d,a]renderedcat slot 0 and scrambled keyed identity (focus/animation/state landed on the wrong row).keyToIndexwas built once and only the moved key rewritten, leaving shifted siblings mis-indexed after an insert/move.RunKeyedMiddleCore<TSink>behind a struct-genericIKeyedMiddleSinkseam (devirtualized, AOT-clean), and the left-to-right loop is replaced with the canonical right-to-left LIS walk. Each item is positioned immediately before its already-placed right neighbour; LIS members stay put and only out-of-LIS movers relocate (minimal moves). Every survivor is patched at its current live position, resolved from a pooledoldRelToPanelint[] that is mutated in lock-step with every Insert/Move so it stays exact — fixing C1 and H1 together. The productionRealKeyedMiddleSinkdrives the identical Mount/Move/UpdateChild/Unmount/ambient behavior as before.oldRelToPanelalso replaces the second pooled key→index dict (one fewer rented dict per call).ChildReconciler.cs (allocation/fast-path)
CanSkipUpdateearly-exit (docs(skills): split SKILL.md into root + on-demand sub-skills #30): mirror the positional path's structural-skip so stable keyed rows avoid thechildren.GetCOM call + full property diff every tick. Includes theForceRenderThroughWrapperguard and the callback-Tag refresh.children.Count(feat(trace): ETW provider for correlated Reactor + WinUI profiling #37): stop re-reading the COMIVector.get_Sizeper suffix iteration.HashSet<int>-returningComputeLIS(which was copied into a 2nd identical set) withComputeLISInto(arr, length, bool[] mask);tails/tailIndices/predecessorscome fromArrayPool. A thinComputeLIS(int[])wrapper is kept for existing tests.ReconcileKeyedMiddlebuffers (test(d3): port upstream d3 tests to raise CI coverage #33):newToOld/matched/inLis/oldRelToPanelfromArrayPool; the key→index dict from a re-entrancy-safe[ThreadStatic]pool. Cleared + returned on every exit (incl. exceptions).Filter(fix(reconciler): preserve Grid children on child type flip (#34) #36): count-pass + singleElement[]fill instead ofList+ToArray.GetKey(test(devtools): add stress harnesses for MCP startup/shutdown lifecycle #38): cacheType.NameviaConcurrentDictionary.KeyedListDiff.cs
SequenceEqualfast path. The no-op path is gated onByKey.Count == oldCount(O(1)) so an unchanged duplicate list (left by a prior duplicate bailout) still re-takes the bailout instead of short-circuiting to Empty.newKeysfromArrayPool<string>(Adding Microsoft SECURITY.MD #2): an explicitnewCountis threaded everywhere (the rented array may be larger); returnedclearArray:truein afinallyvia anApply/ApplyCoresplit.ApplyGeneral(DataGrid cells lost from UIA tree after async commit triggers row state transition #34): computed from the same post-prefix/suffix scratch map the general walk already builds (diff-range churn ≡ full-range churn), removing the O(2n) null-marker pre-pass + second populate.doomedReactorRow[](This repo is missing important files #3), lazymovedRows(refactor: rename Factories.Text → TextBlock, TextElement → TextBlockElement #35), in-placeSyncLastKeysToSourceinstead ofClear()+Add(Add MIT LICENSE file #10),HasDuplicatesreusesstate.Scratchfor 4+ keys (docs: add Blazor as a Microsoft framework in comparative analysis #11), cached null-key diagnostic sample (chore(coverage): clean up coverage config, document unit+selftest merge #41).Tests
New coverage in
tests/Reactor.Tests:ChildReconcilerKeyedMiddleCoreTests): a headlessSimKeyedMiddleSinkdrives the sameRunKeyedMiddleCoreover identity cells (exact production parity, no live-WinUI selftest wall), with a 4-invariant oracle (length, prefix/suffix untouched, per-slot identity+content, every patch hits its claimed survivor) across rotation, full reverse, scramble, block-swap, inserts/removes/duplicates and prefix/suffix offsets. A faithful pre-fix reproduction proves the rotation regression test has teeth (the buggy walk corruptscontent[0]and mis-patches; the real core is clean).KeyedListDiffPoolingTests): twoGC.GetAllocatedBytesForCurrentThreadbudgets — no-op steady-state diff = 0 B/iter, 128-key reorder = ~72 B/diff — that fail if the pooling (This repo is missing a LICENSE file #1/Adding Microsoft SECURITY.MD #2/docs: add Blazor as a Microsoft framework in comparative analysis #11) is reverted.KeyedListDiffTests): an unchanged duplicate list re-bails (verified to fail without theByKey.Countguard).ChildReconcilerLisIntoTests): independent brute-force DP oracle (non-circular), clears stale markers, honorslengthon an oversized pooled mask, and asserts selection never includes a-1sentinel.doomedremoves, churn with shared prefix and suffix,Scratchreuse across a dup bailout).Validation
dotnet test tests/Reactor.Tests— 9843 passed, 0 failed, 64 skipped.dotnet build src/Reactor-c Release— 0 warnings, 0 errors (core lib promotes AOT/trim warnings to errors)./perf: −30.8% [−31.0, −30.6] keyed-list allocation, −32.3% Gen0, keyed reconcile/rps within-noise.