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

[android] add projects to record AOT profiles #4859

Merged
merged 4 commits into from
Feb 25, 2022

Conversation

jonathanpeppers
Copy link
Member

Context: https://github.com/jonathanpeppers/Mono.Profiler.Android#usage-of-the-aot-profiler

Adds projects and instructions for creating AOT profiles for Android.
Additionally, add a new profile for maui-blazor to be used when
$(UsingMicrosoftNETSdkRazor) is true.

CommonMethods.cs has various APIs that we want to include in the
built-in AOT profile. Right now, it most importantly includes usage of
HttpClient and System.Threading.Tasks.

maui.aotprofile.txt is an alphabetical list of methods in the
profile. We can track changes to this file over time.

Results

dotnet new maui on a Pixel 5:

02-23 09:48:40.822  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +470ms
02-23 09:48:42.056  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +485ms
02-23 09:48:43.262  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +465ms
02-23 09:48:44.438  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +471ms
02-23 09:48:45.667  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +473ms
02-23 09:48:46.909  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +458ms
02-23 09:48:48.100  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +462ms
02-23 09:48:49.312  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +463ms
02-23 09:48:50.538  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +461ms
02-23 09:48:51.719  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +465ms
Average(ms): 467.3
Std Err(ms): 2.47229088543849
Std Dev(ms): 7.81807023646003

Same project using MAUI Preview 13 was Average(ms): 490.9.

dotnet new maui-blazor:

02-23 09:51:23.245  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +570ms
02-23 09:51:24.480  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +595ms
02-23 09:51:25.656  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +574ms
02-23 09:51:26.870  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +577ms
02-23 09:51:28.078  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +584ms
02-23 09:51:29.243  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +556ms
02-23 09:51:30.457  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +570ms
02-23 09:51:31.699  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +596ms
02-23 09:51:32.896  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +578ms
02-23 09:51:34.117  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +578ms
Average(ms): 577.8
Std Err(ms): 3.76769897358528
Std Dev(ms): 11.9145102944081

Same project using MAUI Preview 13 was Average(ms): 664.0.

PR Checklist

  • Targets the correct branch
  • Tests are passing (or failures are unrelated)
  • Targets a single property for a single control (or intertwined few properties)
  • Adds the property to the appropriate interface
  • Avoids any changes not essential to the handler property
  • Adds the mapping to the PropertyMapper in the handler
  • Adds the mapping method to the WinUI, Android, iOS, and Standard aspects of the handler
  • Implements the actual property updates (usually in extension methods in the Platform section of Core)
  • Tags ported renderer methods with [PortHandler]
  • Adds an example of the property to the sample project (MainPage)
  • Adds the property to the stub class
  • Implements basic property tests in DeviceTests

Does this PR touch anything that might affect accessibility?

No

@jonathanpeppers
Copy link
Member Author

In-tree tests are failing... because I moved the .aotprofile files to src\ProfiledAot. Will look into it.

Context: https://github.com/jonathanpeppers/Mono.Profiler.Android#usage-of-the-aot-profiler

Adds projects and instructions for creating AOT profiles for Android.
Additionally, add a new profile for `maui-blazor` to be used when
`$(UsingMicrosoftNETSdkRazor)` is `true`.

`CommonMethods.cs` has various APIs that we want to include in the
built-in AOT profile. Right now, it most importantly includes usage of
`HttpClient` and `System.Threading.Tasks`.

`maui.aotprofile.txt` is an alphabetical list of methods in the
profile. We can track changes to this file over time.

~~ Results ~~

`dotnet new maui` on a Pixel 5:

    02-23 09:48:40.822  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +470ms
    02-23 09:48:42.056  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +485ms
    02-23 09:48:43.262  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +465ms
    02-23 09:48:44.438  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +471ms
    02-23 09:48:45.667  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +473ms
    02-23 09:48:46.909  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +458ms
    02-23 09:48:48.100  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +462ms
    02-23 09:48:49.312  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +463ms
    02-23 09:48:50.538  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +461ms
    02-23 09:48:51.719  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +465ms
    Average(ms): 467.3
    Std Err(ms): 2.47229088543849
    Std Dev(ms): 7.81807023646003

Same project using MAUI Preview 13 was `Average(ms): 490.9`.

`dotnet new maui-blazor`:

    02-23 09:51:23.245  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +570ms
    02-23 09:51:24.480  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +595ms
    02-23 09:51:25.656  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +574ms
    02-23 09:51:26.870  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +577ms
    02-23 09:51:28.078  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +584ms
    02-23 09:51:29.243  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +556ms
    02-23 09:51:30.457  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +570ms
    02-23 09:51:31.699  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +596ms
    02-23 09:51:32.896  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +578ms
    02-23 09:51:34.117  1802  1962 I ActivityTaskManager: Displayed com.companyname.foo/crc64808a40cc7e533249.MainActivity: +578ms
    Average(ms): 577.8
    Std Err(ms): 3.76769897358528
    Std Dev(ms): 11.9145102944081

Same project using MAUI Preview 13 was `Average(ms): 664.0`.
Comment on lines +12 to +14
<Exec Command="&quot;$(DotNetToolPath)&quot; new $(App) -o $(Intermediate)" EnvironmentVariables="$(EnvVars)" />
<!-- MainPage.xaml.cs uses CommonMethod.cs -->
<Copy SourceFiles="src/MainPage-$(App).cs" DestinationFiles="$(Intermediate)MainPage.xaml.cs" />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now invokes the template and copies one file over top. So a lot less code now.

Comment on lines 14 to 15
$ ./bin/dotnet/dotnet build src/ProfiledAot/build.proj -p:App=maui
$ ./bin/dotnet/dotnet build src/ProfiledAot/build.proj -p:App=maui-blazor
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instructions have changed now as well.

Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just one minor formatting issue in the README.

@jonathanpeppers jonathanpeppers merged commit 4a0f924 into dotnet:main Feb 25, 2022
@jonathanpeppers jonathanpeppers deleted the ProfiledAOT branch February 25, 2022 19:42
@samhouts samhouts added the area-blazor Blazor Hybrid / Desktop, BlazorWebView label Jul 10, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Dec 23, 2023
@samhouts samhouts added the fixed-in-6.0.200-preview.14.2 Look for this fix in 6.0.200-preview.14.2! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView fixed-in-6.0.200-preview.14.2 Look for this fix in 6.0.200-preview.14.2!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants