Skip to content

Remove FlexPanelGallery and RegeditWinUI XAML-based samples - #59

Merged
Chris Anderson (codemonkeychris) merged 1 commit into
mainfrom
andersonch/remove-xaml-samples
Apr 21, 2026
Merged

Chris Anderson (codemonkeychris) merged 1 commit into
mainfrom
andersonch/remove-xaml-samples

Conversation

@codemonkeychris

Copy link
Copy Markdown
Collaborator

Summary

Removes two samples that use traditional XAML/code-behind patterns instead of Reactor functional components:

  • FlexPanelGallery — uses XAML pages and code-behind, not Reactor's component model
  • RegeditWinUI — XAML-based and redundant with the pure-Reactor \ReactorRegedit\ sample in \samples/apps/regedit/\

These samples were confusing for new users trying to learn Reactor patterns.

Changes

  • Deleted \samples/FlexPanelGallery/\ (14 XAML/CS files)
  • Deleted \samples/apps/regedit-winui/\ (20 files)
  • Removed 3 project entries + 32 build config lines + 3 nesting entries from \Reactor.sln\
  • Updated directory listings in \README.md\ and \CONTRIBUTING.md\

Testing

  • ✅ Unit tests: 5108 passed, 0 failed
  • ✅ Selftests: 471 passed, 1 pre-existing flaky failure (\DataGrid_ScrollPerfRelative\ perf ratio assertion — unrelated)

These samples use traditional XAML/code-behind patterns rather than Reactor
functional components, which is confusing for users trying to learn Reactor.

- FlexPanelGallery: XAML+code-behind, not Reactor patterns
- RegeditWinUI: redundant with the pure-Reactor ReactorRegedit sample

Removed project entries and build configs from Reactor.sln, and updated
directory listings in README.md and CONTRIBUTING.md.

Co-authored-by: Copilot <[email protected]>
@codemonkeychris
Chris Anderson (codemonkeychris) merged commit 5e6fb87 into main Apr 21, 2026
3 checks passed
@codemonkeychris
Chris Anderson (codemonkeychris) deleted the andersonch/remove-xaml-samples branch April 21, 2026 15:36
Alexandre Zollinger Chohfi (azchohfi) added a commit that referenced this pull request Jun 26, 2026
…ce last render

Round 9 Copilot review on 29b2cf3: the #59 key-buffer tail clear ran
Array.Clear(keys, count, keys.Length - count) on every render whenever the
persisted KeyBuffer was larger than the current row count. After the buffer
peaked large and the list then stayed small, this re-nulled the entire
[count..Length] tail on every steady-state full-reuse render -> an O(buffer)
per-render CPU cost on the exact hot path the fast path is meant to keep free.

Fix: null only the slots vacated since the PREVIOUS render ([count..prevCount]).
Slots beyond prevCount were already nulled by the render that vacated them, so a
peaked-then-shrunk buffer is cleared once per shrink transition instead of every
render. The post-render invariant is unchanged (after every render [count..Length]
is still all-null), so GC retention behaviour is identical -- this is a pure CPU
reduction. prevCount is reused for the full-reuse length check too.

Added UseMemoCellsByKey_FullReuse_After_Buffer_Peak_Then_Shrink regression test
(grow 5 -> shrink 3 -> steady) confirming full-reuse still returns the prior
children while the buffer keeps capacity 5.

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

Round 10 Copilot review on 34f071d: the full-reuse fast-path equality scans
called the static object.Equals(items[i], prev[i]), which BOXES both operands
when T is a value type -- 2 boxes per item per render on the steady-state
cache-hit path, directly undermining the zero-allocation goal of #47/#59. The
earlier zero-alloc test used string (reference-type) items, so it never exercised
the boxing path.

Fix: switch all four item-equality comparisons in UseMemoCells<T> and
UseMemoCellsByKey<T,TKey> (both fast-path scans plus both slow-path reuse scans)
to EqualityComparer<T>.Default.Equals -- the repo idiom already used by the
UseState/UseReducer/Observable/PropEntry comparisons. Non-boxing for value types,
identical semantics for reference types, AOT-safe (no reflection). DepsEqual is
left as object.Equals (its operands are already object[] deps -> no boxing).

Added two value-type (int) zero-alloc regression tests, one per arm, that exercise
the boxing path the string-keyed test could not. Verified they FAIL without the
fix at exactly the predicted cost (480000 B / 2000 calls = 240 B/call = 5 items x
2 boxes x 24 B) and pass with it.

Co-authored-by: Copilot <[email protected]>
Alexandre Zollinger Chohfi (azchohfi) added a commit that referenced this pull request Jun 26, 2026
Every component re-render re-runs every hook, so per-render hook
allocations multiply by cells x hooks on data-grid workloads
(StocksGrid). This eliminates the hot-path allocations in the hooks
bookkeeping layer while preserving the rules of hooks (same call
order/count/types every render) and observable semantics.

RenderContext.cs:
- #42 ValueHookState Lock is now lazy/nullable (allocated only when
  threadSafe:true); saves N rows x M hooks of unused Lock objects.
- #43 UseState setter cached on the hook slot (built once, not a new
  display-class + Action<T> every render).
- #44 UseReducer<T> updater and UseReducer<TState,TAction> dispatch
  delegates cached on the hook; dispatch reads the latest reducer from
  state (matches React semantics).
- #45/#46/#48 UseEffect/UseMemo/UseCallback gain arity 1-3 deps
  overloads that compare deps without boxing and allocate the deps
  array only when deps actually change; params overloads kept as
  fallback and now assign Dependencies directly (no extra ToArray).
  UseCallback no longer allocates a ()=>callback wrapper.
- #50 _hooks list pre-sized to new(8) to avoid mount realloc churn.
- #51 ContextHooks uses a struct enumerator (no heap enumerator per
  render); still implements IEnumerable for existing .ToList() callers.
- #52 UseCommand/UseCommand<T> use an inline memo slot instead of a
  per-render factory closure capturing 7 vars.
- #53 UsePersisted setter cached on the hook slot.
- #56 new internal UseDisposableEffect(IDisposable) mount-once helper
  with a stable teardown (no 2 lambdas per render).

Hooks/:
- #47 UseMemoCells/ByKey/ByIndex early full-reuse: return the prior
  children array and skip snapshot/dict allocation on a full cache hit.
- #59 UseMemoCellsByKey computes each key once per item into a buffer
  instead of invoking the key selector twice.
- #55 UseElementFocus caches the requestFocus closure and DispatcherQueue
  in refs instead of allocating + a COM call every render.
- #57 UseResource uses an Interlocked counter id (not Guid.NewGuid) and
  skips the deps-hash rebuild when deps are unchanged; #56 disposes via
  UseDisposableEffect.
- #56 UseMutation/UseInfiniteResource dispose via UseDisposableEffect.

PanelAttachedHooks.cs:
- #60 ApplyRelativePanelAttachedProps reuses a thread-static name-map
  dictionary (with a reentrancy guard for nested RelativePanels) instead
  of allocating one per reconcile.

Tests: tests/Reactor.Tests/HookAllocationPerfTests.cs (25 tests) cover
cached-delegate identity across renders, deps short-circuit (params +
arity), threadSafe Lock still allocated + correct under concurrent
writes (null when not requested), and UseMemoCells/ByKey/ByIndex
cache-hit returning the same prior children array.

The two committed skills/reactor.api.txt copies are regenerated to add
the new public arity overloads (UseDisposableEffect stays internal).

Closes #659

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

Round 9 Copilot review on 29b2cf3: the #59 key-buffer tail clear ran
Array.Clear(keys, count, keys.Length - count) on every render whenever the
persisted KeyBuffer was larger than the current row count. After the buffer
peaked large and the list then stayed small, this re-nulled the entire
[count..Length] tail on every steady-state full-reuse render -> an O(buffer)
per-render CPU cost on the exact hot path the fast path is meant to keep free.

Fix: null only the slots vacated since the PREVIOUS render ([count..prevCount]).
Slots beyond prevCount were already nulled by the render that vacated them, so a
peaked-then-shrunk buffer is cleared once per shrink transition instead of every
render. The post-render invariant is unchanged (after every render [count..Length]
is still all-null), so GC retention behaviour is identical -- this is a pure CPU
reduction. prevCount is reused for the full-reuse length check too.

Added UseMemoCellsByKey_FullReuse_After_Buffer_Peak_Then_Shrink regression test
(grow 5 -> shrink 3 -> steady) confirming full-reuse still returns the prior
children while the buffer keeps capacity 5.

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

Round 10 Copilot review on 34f071d: the full-reuse fast-path equality scans
called the static object.Equals(items[i], prev[i]), which BOXES both operands
when T is a value type -- 2 boxes per item per render on the steady-state
cache-hit path, directly undermining the zero-allocation goal of #47/#59. The
earlier zero-alloc test used string (reference-type) items, so it never exercised
the boxing path.

Fix: switch all four item-equality comparisons in UseMemoCells<T> and
UseMemoCellsByKey<T,TKey> (both fast-path scans plus both slow-path reuse scans)
to EqualityComparer<T>.Default.Equals -- the repo idiom already used by the
UseState/UseReducer/Observable/PropEntry comparisons. Non-boxing for value types,
identical semantics for reference types, AOT-safe (no reflection). DepsEqual is
left as object.Equals (its operands are already object[] deps -> no boxing).

Added two value-type (int) zero-alloc regression tests, one per arm, that exercise
the boxing path the string-keyed test could not. Verified they FAIL without the
fix at exactly the predicted cost (480000 B / 2000 calls = 240 B/call = 5 items x
2 boxes x 24 B) and pass with it.

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.

1 participant