Skip to content

[Windows] Optimize LayoutHandler.Windows.cs (take 3)#26722

Merged
PureWeen merged 13 commits intodotnet:mainfrom
MartyIX:feature/2024-12-19-Optimize-LayoutHandler-for-Windows-3
Dec 24, 2024
Merged

[Windows] Optimize LayoutHandler.Windows.cs (take 3)#26722
PureWeen merged 13 commits intodotnet:mainfrom
MartyIX:feature/2024-12-19-Optimize-LayoutHandler-for-Windows-3

Conversation

@MartyIX
Copy link
Contributor

@MartyIX MartyIX commented Dec 19, 2024

This PR is the same as #26460 but it applies this @jonathanpeppers's suggestion: #26460 (comment). I find it to be a biggish change so I created a new PR to make it easy to compare this one and the previous one #26460.

Description of Change

I've been scratching my head how to improve performance of LayoutHandler and it seems that storing Children of PlatformView leads to a significant performance gain in my test scenario (#21787). This PR is a replacement for #26161 that implements @mattleibow's suggestion from the previous PR. Interestingly, the suggestion allows to easily use CachedChildren in more places and thus improve performance a bit more.

Explanation from @Sergio0694:

"Do we have an idea what the property [i.e. Panel.Children] does underneath?"

Assuming that's some WinUI Panel control, accessing that property will invoke the get_Children method on the native WinRT object, then marshal the returned IInspectable* pointer to a C# object (ie. it'll go find the existing RCW for it, or create a new one if it doesn't exist already).

Speedscope

image

-> 97% improvement for IPanelMethods.get_Children.

Issues Fixed

Contributes to #21787

@MartyIX MartyIX requested a review from a team as a code owner December 19, 2024 10:15
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Dec 19, 2024
@dotnet-policy-service
Copy link
Contributor

Hey there @MartyIX! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@jonathanpeppers
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@MartyIX MartyIX requested review from Foda and jonathanpeppers and removed request for tj-devel709 December 20, 2024 07:43
@PureWeen PureWeen added the area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter label Dec 20, 2024
@PureWeen PureWeen merged commit 4597776 into dotnet:main Dec 24, 2024
@MartyIX MartyIX deleted the feature/2024-12-19-Optimize-LayoutHandler-for-Windows-3 branch December 24, 2024 20:50
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter community ✨ Community Contribution

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants