-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WinUI] Perf when creating non-trivial grids (and other visual controls) #21818
[WinUI] Perf when creating non-trivial grids (and other visual controls) #21818
Conversation
@PureWeen What do you think please? |
This looks interesting! performance should be on top of the list, and changes like this, as well as to other platforms should be really a priority. Since it is in the core, would love to see this going forward. Not developing anything for Windows, but super interested for Android and iOS |
@AdamEssenmacher Can the slowdown be caused by #21809 please? |
@MartyIX I don't think so. Your Labels are getting GC'ed. It does seem like there's a memory leak in this sample though, so the slowdown could be related to that in some way. It's just not the propagating leak I describe in #21809 I'll further observe that the major leak appearing in this sample goes away and the time to run each batch becomes very consistent if you modify the batch generation method like:
So, I suspect this batch test has something else entirely going on, most likely related to UI elements being added to the visual tree that never get a chance to be fully flushed out to the screen. |
// TranslationX does the work that is necessary to make other properties work. | ||
nameof(IView.TranslationY), | ||
nameof(IView.Scale), | ||
nameof(IView.ScaleX), | ||
nameof(IView.ScaleY), | ||
nameof(IView.Rotation), | ||
nameof(IView.RotationX), | ||
nameof(IView.RotationY), | ||
nameof(IView.AnchorX), | ||
nameof(IView.AnchorY), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this seems like it could be a temporary solution if it doesn't change any behavior.
Does this make ordering matter? What if you have code such as:
view.TranslateX = 10;
view.TranslateY = 10;
// set the other properties *after* TranslateX
For this related change for Android:
I believe it changed some behavior with handlers, so we put it in the next .NET release. So this change might be more suitable for .NET 9, so it could get more testing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this seems like it could be a temporary solution if it doesn't change any behavior.
Mostly I was hoping that this PR would nudge the MAUI team to recognize that there is a lot of performance on the table and even with medium effort, it seems like one can make it substantially faster. I don't want really to put too much effort in this because this is not trivial for me and there is too much space for "it's nice but we decided we'll do X instead". This simply requires some coordination from the code owners. I'm not even the best to implement something like this.
For the record, I believe that your idea with default values it much much better because it would save (especially on Windows) a ton of time. But again, how can I evaluate the idea? Maybe it has been on the table before and it was rejected because who know what would it lead to.
So all in all this PR is just a demonstration that "it looks like that with a rather simple change, it can be about 20% faster". Unfortunately, for me it's still not sufficient because I need something like up to 100ms to draw a complex grid ... :-(.
Also it's not like I'm lazy. Today, for example, I spent whole day fixing a bug that spans somewhere between MAUI and WinUI and I'm on the verge of giving up ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need something like up to 100ms to draw a complex grid
Have you thought about using SkiaSharp for this one piece of UI? You likely don't need all the rows & columns to be actual MAUI (& WinUI) Labels?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need something like up to 100ms to draw a complex grid
Have you thought about using SkiaSharp for this one piece of UI? You likely don't need all the rows & columns to be actual MAUI (& WinUI) Labels?
I haven't mostly because it feels hard to create a data grid in 2D graphics. I don't know much about SkiaSharp. Is it somehow easy to create such data grid? I mean it sounds like a lot of low-level computing on my side to make it work.
Moreover, values in "labels" would not be easy to copy & paste, or would it?
Maybe a custom layout would be a way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonathanpeppers I have come up with a different approach in #23987 (the main idea is: https://github.com/dotnet/maui/pull/23987/files#diff-fe5090f560d95c536e43dfc5f39442add6ad2d8eb555d675bdb4a0f82a30793dR35). Could you please take a look?
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
Description of Change
Notes:
Clicking "Batch Generate Grid" multiple times lead to ever increasing time to finish the operation. I'm not sure why.
Relevant issue [performance] all
PropertyMapper
's set the same values over and over #17303This PR is mostly a bait to attract the MAUI team's attention to the problem that it seems it's not that hard to improve status quo substantially. However, my discussion with @jonathanpeppers1 somewhat suggests that the approach of this PR is not the best (mediocre at best I guess):
me:
Jonathan:
Master
851 ms
PR:
676 ms
-> 20% faster.
Issues Fixed
Contributes to #21787
Footnotes
I hope he doesn't mind me copying it here. ↩