Skip to content

perf(grid): Index the definition collections (backport #24233) - #25748

Merged
agneszitte merged 1 commit into
servicing/6.8from
mergify/bp/servicing/6.8/pr-24233
Oct 27, 2026
Merged

agneszitte merged 1 commit into
servicing/6.8from
mergify/bp/servicing/6.8/pr-24233

Conversation

@mergify

@mergify mergify Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #24224

PR Type:

🔄 Refactoring (no functional changes, no api changes)

What changed? 🚀

ValidateDefinitions iterated definitions.GetItems(), which hands back the backing DependencyObjectCollection as IEnumerable<DefinitionBase>. Its GetEnumerator returns IEnumerator<T>, boxing the List<T>.Enumerator struct, and the method runs twice per Grid measure — once for rows, once for columns.

Loop by index instead. DefinitionCollectionBase already exposed Count and GetItem(int), and GetItem is _inner[index] — the same sequence the enumerator walks — so no new API was needed. GetItems() then had no callers left and is removed rather than left dead.

Measured impact 📊

Workload Metric Before After Δ
grid.full-pass alloc / pass 79,113 B 51,833 B −34.5 %
grid.full-pass alloc / element 58.0 B 38.0 B −34.5 %
grid.full-pass time / pass 3.11 ms 3.08 ms ±0 (noise)

Workload run alone in both configurations, change reverted and re-applied on the current tree, 5 runs each, median. Allocation figures byte-identical across runs.

27,280 B saved over 341 grids = 80 B per grid per pass — two boxed List<T>.Enumerators at 40 B each, one for rows and one for columns, matching the constant measured independently in VisualTreeHelper.

Validation ✅

Runtime tests, Skia Desktop — same 937-test layout/rendering/framework suite as the visual-tree PR, set-compared against a baseline build: 0 new failures, 0 newly passing.

PR Checklist ✅

  • 🧪 Added Runtime tests, UI tests, or a manual test sample (for bug fixes / features, if applicable)
  • 📚 Docs have been added/updated following the documentation template (for bug fixes / features) — n/a, no API or behaviour change for app authors
  • 🖼️ Validated PR Screenshots Compare Test Run results. — to check once CI has run
  • ❗ Contains NO breaking changes
  • 👀 Reviewed 2 other open pull requests (optional but appreciated!)

This is an automatic backport of pull request #24233 done by [Mergify](https://mergify.com).

ValidateDefinitions iterated definitions.GetItems(), which hands back the
backing DependencyObjectCollection as IEnumerable<DefinitionBase>. Its
GetEnumerator returns IEnumerator<T>, boxing the List<T>.Enumerator
struct, and the method runs twice per Grid measure -- once for rows, once
for columns.

Loop by index instead. DefinitionCollectionBase already exposed Count and
GetItem(int), and GetItem is _inner[index], the same sequence the
enumerator walks, so no new API was needed. GetItems() had exactly one
caller and is removed rather than left dead.

Measured (specs/059-performance-improvements): a grid layout pass drops
34.5% of its allocations, and the 27,280 B saved is exactly 80 B per grid
-- two boxed List<T>.Enumerators, matching the 40 B constant measured
independently in the visual-tree accessors. Time is unchanged. 937 runtime
tests: identical pass/fail sets, 0 new failures.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015DSdL5YzLhjx8CeGXZf1Au
(cherry picked from commit db7973e)
@mergify mergify Bot mentioned this pull request Oct 27, 2026
1 of 5 tasks
@agneszitte
agneszitte merged commit e570a57 into servicing/6.8 Oct 27, 2026
12 of 20 checks passed
@agneszitte
agneszitte deleted the mergify/bp/servicing/6.8/pr-24233 branch October 27, 2026 21:40
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

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