Skip to content
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

[Bug] Evaluate use of string comparisons inside Maui.Core #3085

Closed
PureWeen opened this issue Oct 22, 2021 · 2 comments
Closed

[Bug] Evaluate use of string comparisons inside Maui.Core #3085

PureWeen opened this issue Oct 22, 2021 · 2 comments
Labels
legacy-area-perf Startup / Runtime performance platform/android 🤖 s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working t/perf The issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf)
Milestone

Comments

@PureWeen
Copy link
Member

PureWeen commented Oct 22, 2021

Description

From @grendello

with Profiled AOT and dotnet/android#6311 this PR we can get it down to less than 900ms
with a sample that has a handful of controls (11 I think)
I see that MAUI Core uses a lot of dictionaries with culture-aware string comparer
it's a major source of slowdown usually
it might be a good idea to use StringComparer.Ordinal if possible
or StringComparer.OrdinalIgnoreCase if needed
one result in the above PR is interesting, namely the Displayed time for default settings (i.g. no AOT)
it shows that MAUI spends a LOT of time JIT-ing between OnCreate is called and the activity is fully rendered
this goes away with Profiled AOT, which is faster by ~400ms than the default settings
one of the speed ups in the above PR is that we no longer use string comparison when searching for assemblies as Mono requests them of us
what is done instead, is we generate on build time the name hashes and store the lookup tables sorted by hash (separately for 32 and 64-bit apps)
and then when Mono asks us to load the assembly, we generate the hash from provided name and use that to binary search the table of known assemblies
perhaps MAUI could do that with some of string processing you do?
we're using xxHash which is very, very fast
https://cyan4973.github.io/xxHash/

@PureWeen PureWeen added t/bug Something isn't working legacy-area-perf Startup / Runtime performance platform/android 🤖 labels Oct 22, 2021
@Redth Redth added this to the 6.0.200-preview.12 milestone Oct 22, 2021
@jpobst
Copy link
Contributor

jpobst commented Oct 25, 2021

Using culture-aware comparisons can also lead to incredibly hard to debug errors. 😉

dotnet/java-interop#879

There are code analyzers you can enable to ensure your code fixes them all.

@kristinx0211 kristinx0211 added the s/verified Verified / Reproducible Issue ready for Engineering Triage label Mar 10, 2022
@Redth Redth modified the milestones: 6.0.300-rc.2, 6.0.300-rc.3 Apr 20, 2022
@jonathanpeppers
Copy link
Member

I fixed this repo-wide in:

Going forward, you'd get a build error if you did a culture-aware comparison on accident.

@ghost ghost locked as resolved and limited conversation to collaborators May 21, 2022
@Eilon Eilon added the t/perf The issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf) label May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
legacy-area-perf Startup / Runtime performance platform/android 🤖 s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working t/perf The issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf)
Projects
None yet
Development

No branches or pull requests

6 participants