Repository navigation
perf(composition): Walk shapes by index on the frame path (backport #24231) - #25751
Merged
agneszitte merged 1 commit intoOct 27, 2026
Merged
Conversation
RequiresRepaintOnEveryFrame, DamageRegionSamplingMargin and CanPaint are queried once per shape element per frame, and each was a LINQ chain, so every frame allocated a collection enumerator, one or two iterators and a closure per shape visual. BorderVisual already implements the same two members as plain expressions. Walk the collection by index instead. DamageRegionSamplingMargin keeps a `seen` flag so DefaultIfEmpty(0f) semantics are preserved exactly: 0 is returned when there is no sprite shape at all, rather than clamping a set of margins up to 0. Measured on the same 1561-element rounded tree (specs/059-performance-improvements): paint allocations drop from 382 KB to 272 KB per frame (-29%), and to -48% cumulatively against the tree before the clip-path fix. Rendering 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 b0e17dd)
1 of 5 tasks
agneszitte
approved these changes
Oct 27, 2026
Contributor
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
This was referenced Nov 9, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
GitHub Issue: closes #24222
PR Type:
🔄 Refactoring (no functional changes, no api changes)
What changed? 🚀
RequiresRepaintOnEveryFrame,DamageRegionSamplingMarginandCanPaint()are queried once per shape element per frame, and each was a LINQ chain — so every frame allocated a collection enumerator, one or two iterators and a closure per shape visual.BorderVisualalready implements the equivalent members as plain expressions.Walk the collection by index instead.
DamageRegionSamplingMarginkeeps aseenflag soDefaultIfEmpty(0f)semantics are preserved exactly: 0 is returned when there is no sprite shape at all, rather than clamping a set of margins up to 0, which a naiveMaxstarting from 0 would do.Measured impact 📊
render.full-paintrender.full-paintrender.full-paintSame 1,561-element rounded tree, paint only, 5 runs each, median. Allocation figures vary by <5 B across runs. Measured on a tree that already has the
RectangleClipcache applied.Validation ✅
Same suite as the clip-path PR (
Given_Border,Given_ContainerVisual,Given_ShapeVisual,Given_Visual_Damage,Given_UIElement,Windows_UI_Xaml_Shapes.*): 671 run, 654 passed, 16 failed, set-compared against a baseline build — 0 new failures, 0 newly passing.PR Checklist ✅
Screenshots Compare Test Runresults. — to check once CI has runThis is an automatic backport of pull request #24231 done by [Mergify](https://mergify.com).