Skip to content

perf(binding): Port WinUI PropertyPathParser - #26586

Draft
MartinZikmund wants to merge 3 commits into
masterfrom
dev/mazi/perf2026-propertypath
Draft

MartinZikmund wants to merge 3 commits into
masterfrom
dev/mazi/perf2026-propertypath

Conversation

@MartinZikmund

@MartinZikmund MartinZikmund commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

GitHub Issue: Part of #24093

PR Type:

🔄 Refactoring

What changed? 🚀

Split out of #24094 (originally by @morning4coffe-dev), which now only carries the opt-in XamlOptionalChanges part. This piece is always on, so it gets its own review.

Ports WinUI's PropertyPathParser and PropertyPathStepDescriptor allocation rework (fd139f17, mirrored from upstream main 3c9c168844f):

  • The per-step descriptor class hierarchy becomes a compact tagged value. The first two descriptors are stored inline, and only longer paths spill to the heap.
  • Parsing and indexers use spans, removing several Substring/Split/Replace/LINQ allocations. MetadataAPI gains span overloads for attached-property lookup.
  • Behaviour change: indexer parsing now follows WinUI's IsNumericIndex and the CRT's iswdigit/_wtoi. An empty index becomes a string indexer, supported non-ASCII digits can form integer indices, and overflowing indices saturate at int.MaxValue.

Adds a propertypath area to the WinUI port sync (build/winui-sync/areas/propertypath.json). The ported files' MUX Reference headers carry no version, because the area file records it.

Important

WIP: blocked until WinUI merges the rework into a stable release. The port mirrors upstream main: fd139f17 ("Reduce allocations for PropertyPathParser") and ee197a29 ("Avoid more heap allocs for PropertyPaths"). Both are on main/winui3/main and in 1.8.12, but not in the latest stable tag winui3/release/2.7.0, which still ships the older (1.5.5-era) parser. 2.7.0 is not an ancestor of winui3/main.

The area is recorded at 2.7.0 for now, so the port is ahead of its baseline, and PropertyPathCommonNames.{h,cpp} can't be mapped upstream because they don't exist at that tag. Once a stable 2.x tag contains ee197a29, this PR will be re-onboarded with /winui-sync-onboard: baseline moved to that tag, PropertyPathCommonNames mapped on both sides, line-by-line review and workaround audit against it.

Validation (rebased on master 11e833a)

  • Compile: Uno.UI.UnitTests (net10.0 override, analyzers on): 0 warnings, 0 errors.
  • Unit tests: full Uno.UI.UnitTests suite, 4,719 passed, 0 failed (Given_PropertyPathParser + Given_BindingPath: 97/97).
  • WinUI sync tooling: detection reports propertypath up to date at 2.7.0; tooling tests 138/138.

Performance

Headless Skia app with Fluent resources (x64, net10.0, DOTNET_TieredCompilation=0), one process per scenario, 4 interleaved A/B rounds against master. Allocations are UI-thread bytes and exact: a master-vs-master null run drifted 0.00%. A time change is bold only when it is larger than that scenario's null drift and the A/B ranges don't overlap; anything else is marked noise. Background load on the machine made some timings noisy.

Scenario Allocated per iteration Δ alloc Per unit Time per iteration (median) Δ time Null drift
900 {Binding}s (Name, Address.City, Tags[1]) 16,857,554 → 16,857,554 B 0 — 17.48 → 17.24 ms −1.4% (noise) ±3.1%
100 Button/CheckBox × 4 visual-state changes 745,659 → 648,059 B −13.09% −244 B 2.04 → 1.85 ms −9.5% (noise) ±7.7%
Mixed page: 40 × 7 Fluent controls 90,441,326 → 90,441,326 B 0 — 269.08 → 274.47 ms +2.0% (noise) ±3.1%
200k Tag set/get 0 → 0 B 0 — 18.55 → 18.52 ms −0.2% (noise) ±6.1%
30k property-path parses (Name / First.Second / Items[1024]) 5,920,080 → 2,960,080 B −50.00% −99 B 2.50 → 1.69 ms −32.5% ±24.0%
Editable ComboBox, DisplayMemberPath over DO items, 200 selections 17,260,752 → 17,260,752 B 0 — 119.71 → 120.01 ms +0.2% (noise) ±3.9%

Parsing a property path allocates half as much (−99 B per parse on average across the three shapes) and runs a third faster. The visual-state saving (−244 B per state change, −13%) comes from this PR's BindingPath property-name comparison changes, which VisualStateGroup runs on every state change. {Binding} and the DisplayMemberPath scenario are unchanged.

PR Checklist ✅

🤖 Generated with Claude Code

https://claude.ai/code/session_01TXMNu1LMuUpziGZWHVDmpX

Copilot AI balanced review requested due to automatic review settings November 18, 2026 10:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@mergify

mergify Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is a draft, so it cannot be queued yet. Mark it as ready for review to get the box back.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 31s —— View job


Review of PR #26586: Port WinUI PropertyPathParser

  • Read the diff and the surrounding context
  • Review the parser, descriptor, BindingPath and MetadataAPI changes
  • Post findings

Verdict: ship. I found no blocking issues, and I only read the diff. I did not build the PR or run its tests.

Findings: 0 high, 0 medium, 1 low (inline: the non-ASCII digit classification vs conversion mismatch).

What I checked

  • Parser port: it keeps WinUI's control flow. The (/) scan now checks the bounds before indexing, which removes a latent out-of-range read in the old code. Embedded \0 truncation, empty-path handling and overflow saturation in ParseIntIndexer are correct. index > (int.MaxValue - digit) / 10 is the exact overflow bound.
  • Storage: the two inline InlineArray slots plus the overflow list are consistent. GetDescriptorAt is bounds-checked, and descriptors are only published by FinalizeDescriptors after a successful parse, so a throwing parse leaves the parser unchanged.
  • SetSource called twice: it now throws COMException, where the old code silently returned. The only production caller (ComboBox.partial.mux.cs) uses a fresh parser each time, and a test covers the new behaviour.
  • BindingPath and BindingItem: GetLeafPropertyName and EqualsIgnoringParenthesis match the old Split/Replace semantics. The is '(' or ')' pattern binds correctly after &&.
  • Conventions: MUX headers, #nullable enable, the .mux.cs/.uno.cs split and the sync areas.json entry look consistent with the repo rules. There are no new warning suppressions and no skipped tests.

Notes

  • The indexer parsing change is described as a behaviour change, but the checklist says "NO breaking changes". Consider a line in the PR description or release notes for apps that bind to […] with non-ASCII or empty indices.
  • The validation covers the net11.0 unit tests only. A quick runtime sanity run of a binding-heavy sample (for example ComboBox DisplayMemberPath) would round it out.
    · Branch: dev/mazi/perf2026-propertypath

=> start == 0 && length == source.Length ? source : source.Substring(start, length);

// WinUI uses the CRT's C-locale wide-digit table, not the newer Unicode tables in .NET.
// Its classification includes digits that _wtoi cannot convert.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low / question: IsWideDigit accepts ², ³, ¹ (and the other ranges missing from GetWideDigitValue, e.g. ߀ and ႐), but GetWideDigitValue returns -1 for them. So [²] is classified as an int indexer and ParseIntIndexer returns 0, and [5²] silently becomes 5. I understand this mirrors iswdigit plus _wtoi on WinUI, and the tests may already cover it. Because it turns what was a string indexer in Uno into a silent [0] lookup, a short comment saying the divergence is intentional parity would help the next reader avoid "fixing" it.

@github-actions github-actions Bot added area/build Categorizes an issue or PR as relevant to build infrastructure area/automation Categorizes an issue or PR as relevant to project automation labels Nov 18, 2026
Comment on lines +45 to +52
if (lengths[i] == targetLength)
{
// Length matches - now do the full string comparison
if (name.SequenceEqual(s_commonPropertyNames[i]))
{
return s_commonPropertyNames[i];
}
}
@unodevops

Copy link
Copy Markdown
Contributor

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

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 247322 found UI Test snapshots differences: skia-linux-screenshots: 254, skia-windows-screenshots: 263

Details
  • skia-linux-screenshots: 254 changed over 2500

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AutomationProperties_AutomationId.png-dark
    • Border_CornerRadius_Binding.png-dark
    • Border_CornerRadius_Binding.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • Accessibility_Showcase.png
    • AppWindowTitleBar Properties.png-dark
    • Buttons.png-dark
    • Buttons.png
    • AutomationProperties_StructureAndProps.png
    • BasicAcrylicBrushTest.png-dark
    • BasicAcrylicBrushTest.png
    • Border_CornerRadius_BorderThickness.png-dark
    • Border_CornerRadius_BorderThickness.png
    • AppWindowTitleBar Properties.png
    • AutomationProperties_AutomationId.png
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
    • CalendarView_Theming.png-dark
    • AnimatedBackVisualSourceSamplePage.png
  • skia-windows-screenshots: 263 changed over 2500

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedBackVisualSourceSamplePage.png
    • AppWindowTitleBar Properties.png
    • AutomationProperties_AutomationId.png-dark
    • AutomationProperties_AutomationId.png
    • BasicAcrylicBrushTest2.png-dark
    • BasicAcrylicBrushTest2.png
    • Border_CornerRadius_Binding.png-dark
    • Border_CornerRadius_Binding.png
    • AppWindowTitleBar Properties.png-dark
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • ComboBox_MaxDropdownHeight.png-dark
    • ComboBox_MaxDropdownHeight.png
    • AutomationProperties_StructureAndProps.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • ColorPickerSample.png-dark
    • ColorPickerSample.png
    • Basics.png-dark

@MartinZikmund MartinZikmund added the blocked/winui Categorizes an issue as blocked by waiting for a fix or change on WinUI label Nov 24, 2026
@MartinZikmund
MartinZikmund marked this pull request as draft November 24, 2026 08:46
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/perf2026-propertypath branch from b4dddd0 to 6eba793 Compare November 24, 2026 08:53
@unodevops

Copy link
Copy Markdown
Contributor

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

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 248686 found UI Test snapshots differences: skia-linux-screenshots: 255, skia-windows-screenshots: 275

Details
  • skia-linux-screenshots: 255 changed over 2504

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Border_CornerRadius_BorderThickness.png-dark
    • Border_CornerRadius_BorderThickness.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png
    • Accessibility_Showcase.png-dark
    • AnimatedVisualsTestbedPage.png
    • AnimatedVisualsTestbedPage.png-dark
    • AppWindowTitleBar Properties.png
    • BasicAcrylicBrushTest.png-dark
    • BasicAcrylicBrushTest.png
    • Border_CornerRadius_Binding.png-dark
    • BitmapIcon_Foreground.png-dark
    • Border_CornerRadius_Binding.png
    • BitmapIcon_Foreground.png
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • CompositionNineGridBrush_Source_Changes.png-dark
  • skia-windows-screenshots: 275 changed over 2504

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
    • ComboBox_MaxDropdownHeight.png-dark
    • ComboBox_MaxDropdownHeight.png
    • Accessibility_Showcase.png-dark
    • AnimatedBackVisualSourceSamplePage.png
    • AnimatedVisualsTestbedPage.png-dark
    • AutomationProperties_StructureAndProps.png-dark
    • AutomationProperties_AutomationId.png
    • AnimatedVisualsTestbedPage.png
    • BasicAcrylicBrushTest2.png-dark
    • BasicAcrylicBrushTest2.png
    • ButtonClippingTestsControl.png-dark
    • ClipboardTests.png
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AppWindowTitleBar Properties.png
    • Basics.png-dark
    • Basics.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation area/build Categorizes an issue or PR as relevant to build infrastructure blocked/winui Categorizes an issue as blocked by waiting for a fix or change on WinUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants