Skip to content

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

Closed

Description

@PureWeen

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/

Activity

  1. added this to the 6.0.200-preview.12 milestone on Oct 22, 2021
  2. jpobst commented on Oct 25, 2021

    @jpobst
    Contributor

    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.

  3. added
    s/verifiedVerified / Reproducible Issue ready for Engineering Triage
    on Mar 10, 2022
  4. jonathanpeppers commented on Apr 20, 2022

    @jonathanpeppers
    Member

    I fixed this repo-wide in:

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

  5. ghost locked as resolved and limited conversation to collaborators on May 21, 2022
  6. added
    perf/generalThe issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf)
    on May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    legacy-area-perfStartup / Runtime performanceperf/generalThe issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf)platform/androids/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions