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

[Xamarin.Android.Build.Tasks] fast path for <CheckClientHandlerType/> #7652

Merged

Conversation

jonathanpeppers
Copy link
Member

@jonathanpeppers jonathanpeppers commented Dec 21, 2022

dotnet trace of a dotnet new maui project, I noticed this was
happening on any build:

65.94ms xamarin.android.build.tasks!Xamarin.Android.Tasks.CheckClientHandlerType.RunTask()

Checking outside of a profiler, a .binlog says:

CheckClientHandlerType = 55 ms

This was added in 311b41e, so it is only in main & .NET 8. Maybe when
we timed this before, it wasn't a MAUI app?

Looking at the stack trace, most of the time is spent loading
assemblies with Mono.Cecil.

Let's add a check at the beginning for the two most common values:

  • .NET 6+: Xamarin.Android.Net.AndroidMessageHandler
  • Classic: Xamarin.Android.Net.AndroidClientHandler

And we can return early in these cases.

After these changes, I get:

CheckClientHandlerType = 2 ms

This should save ~53ms on any build w/ common settings for
$(AndroidHttpClientHandlerType).

@jonathanpeppers jonathanpeppers force-pushed the _CheckAndroidHttpClientHandlerType branch from 6e5ed2f to 9c890d9 Compare December 22, 2022 20:32
@jonathanpeppers jonathanpeppers changed the title [Xamarin.Android.Build.Tasks] add Inputs/Outputs to _CheckAndroidHttpClientHandlerType [Xamarin.Android.Build.Tasks] fast path for <CheckClientHandlerType/> Dec 22, 2022
@jonathanpeppers
Copy link
Member Author

/azp run

@jonathanpeppers jonathanpeppers force-pushed the _CheckAndroidHttpClientHandlerType branch from 9c890d9 to efead2b Compare January 3, 2023 18:49
`dotnet trace` of a `dotnet new maui` project, I noticed this was
happening on *any* build:

    65.94ms xamarin.android.build.tasks!Xamarin.Android.Tasks.CheckClientHandlerType.RunTask()

Checking outside of a profiler, a `.binlog` says:

    CheckClientHandlerType = 55 ms

This was added in 311b41e, so it is only in main & .NET 8. Maybe when
we timed this before, it wasn't a MAUI app?

Looking at the stack trace, most of the time is spent loading
assemblies with Mono.Cecil.

Let's add a check at the beginning for the two most common values:

* .NET 6+: `Xamarin.Android.Net.AndroidMessageHandler`
* Classic: `Xamarin.Android.Net.AndroidClientHandler`

And we can return early in these cases.

After these changes, I get:

    CheckClientHandlerType = 2 ms

This should save ~53ms on any build w/ common settings for
`$(AndroidHttpClientHandlerType)`.
@jonathanpeppers jonathanpeppers force-pushed the _CheckAndroidHttpClientHandlerType branch from efead2b to bce18d6 Compare January 3, 2023 21:34
@jonathanpeppers jonathanpeppers marked this pull request as ready for review January 3, 2023 21:36
@dellis1972 dellis1972 merged commit d4c2a5e into xamarin:main Jan 4, 2023
@jonathanpeppers jonathanpeppers deleted the _CheckAndroidHttpClientHandlerType branch January 4, 2023 14:20
grendello added a commit to grendello/xamarin-android that referenced this pull request Jan 17, 2023
* main:
  [Xamarin.Android.Build.Tasks] skip XA1034 logic in some cases (xamarin#7680)
  [ci] Move OneLocBuild task to scheduled pipeline (xamarin#7679)
  [Mono.Android] ServerCertificateValidationCallback() and redirects (xamarin#7662)
  Bump to xamarin/java.interop@cf80deb7 (xamarin#7664)
  Localized file check-in by OneLocBuild (xamarin#7668)
  [api-merge] Correctly compute //method/@deprecated-since (xamarin#7645)
  [Xamarin.Android.Build.Tasks] _Microsoft.Android.Resource.Designer (xamarin#6427)
  [Xamarin.Android.Build.Tasks] downgrade d8/r8 `warning` messages to `info` (xamarin#7643)
  [Xamarin.Android.Build.Tasks] fix cases of missing `@(Reference)` (xamarin#7642)
  [Xamarin.Android.Build.Tasks] delay ToJniName calls in ManifestDocument (xamarin#7653)
  [Xamarin.Android.Build.Tasks] fast path for `<CheckClientHandlerType/>` (xamarin#7652)
@github-actions github-actions bot locked and limited conversation to collaborators Jan 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants