Skip to content

Commit 22b3da8

Browse files
jonathanpeppersrmarinho
authored andcommitted
[android] add AOT profile for dotnet new maui -sc (#28172)
There is a new "sample content" switch for the `dotnet new maui` template that brings in various NuGets and things automatically. None of these things are in the built-in AOT profile, so let's record one specifically for this template. I also updated the other AOT profiles, as I can see some of the latest changes in dotnet/main/main calls different methods on startup. Testing an average of 10 runs on a Pixel 7 Pro: $ dotnet new maui Before: Average(ms): 446 Std Err(ms): 2.28035085019828 Std Dev(ms): 7.21110255092798 After: Average(ms): 441 Std Err(ms): 5.09901951359278 Std Dev(ms): 16.1245154965971 $ dotnet new maui -sc Before: Average(ms): 1073.6 Std Err(ms): 8.35623519694525 Std Dev(ms): 26.4247358864127 After: Average(ms): 832.1 Std Err(ms): 5.65773806392625 Std Dev(ms): 17.8913386866383 Since `dotnet new maui -sc` is still a bit slower, I will investigate how to improve this in other PRs.
1 parent dbbfc0d commit 22b3da8

File tree

9 files changed

+10188
-204
lines changed

9 files changed

+10188
-204
lines changed

src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
<ItemGroup Condition="'$(AndroidEnableProfiledAot)' == 'true' and '$(MauiUseDefaultAotProfile)' != 'false'">
3434
<AndroidAotProfile Include="$(MSBuildThisFileDirectory)maui.aotprofile" />
35+
<AndroidAotProfile Include="$(MSBuildThisFileDirectory)maui-sc.aotprofile" />
3536
<AndroidAotProfile Include="$(MSBuildThisFileDirectory)maui-blazor.aotprofile" />
3637
</ItemGroup>
3738

src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/maui-blazor.aotprofile.txt

Lines changed: 31 additions & 30 deletions
Large diffs are not rendered by default.

src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/maui-sc.aotprofile.txt

Lines changed: 10065 additions & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.

src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/maui.aotprofile.txt

Lines changed: 69 additions & 164 deletions
Large diffs are not rendered by default.

src/ProfiledAot/README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,18 @@ https://github.com/jonathanpeppers/Mono.Profiler.Android#usage-of-the-aot-profil
99
Build MAUI following the instructions at [DEVELOPMENT.md][0]. Make
1010
sure to build with `--configuration=Release`.
1111

12-
Run the `Record` target on each project:
12+
Run the `Record` target on each "type" of project template:
1313

1414
```bash
15-
$ ./bin/dotnet/dotnet build src/ProfiledAot/build.proj -bl -p:App=maui
16-
$ ./bin/dotnet/dotnet build src/ProfiledAot/build.proj -bl -p:App=maui-blazor
15+
./.dotnet/dotnet build src/ProfiledAot/build.proj -bl -p:App=maui
16+
./.dotnet/dotnet build src/ProfiledAot/build.proj -bl -p:App=maui-sc
17+
./.dotnet/dotnet build src/ProfiledAot/build.proj -bl -p:App=maui-blazor
1718
```
1819

20+
* `maui` is `dotnet new maui`
21+
* `maui-sc` is `dotnet new maui -sc` or (sample content)
22+
* `maui-blazor` is `dotnet new maui-blazor`
23+
1924
You can also use `-r android-x64`, if you'd prefer an x86_64 emulator.
2025

2126
`maui.aotprofile.txt` and `maui-blazor.aotprofile.txt` are a list of
@@ -37,9 +42,9 @@ Build MAUI again with `--configuration=Release` (see
3742
Create a new project and run it:
3843

3944
```bash
40-
$ mkdir foo && cd foo
41-
$ ../bin/dotnet/dotnet new maui
42-
$ ../bin/dotnet/dotnet build -c Release -t:Run -f net7.0-android
45+
mkdir foo && cd foo
46+
../.dotnet/dotnet new maui
47+
../.dotnet/dotnet build -c Release -t:Run -f net7.0-android
4348
```
4449

4550
Run the app a few times and make sure you get good launch times:
@@ -75,8 +80,8 @@ rm -r ~\.nuget\packages\*\*-dev\
7580
To verify what methods are AOT'd, clear the log and enable AOT logging:
7681

7782
```bash
78-
$ adb logcat -c
79-
$ adb shell setprop debug.mono.log default,timing=bare,assembly,mono_log_level=debug,mono_log_mask=aot
83+
adb logcat -c
84+
adb shell setprop debug.mono.log default,timing=bare,assembly,mono_log_level=debug,mono_log_mask=aot
8085
```
8186

8287
Restart the app, and you should be able to see messages like:

src/ProfiledAot/build.proj

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,16 @@
77
<EnvVars>DOTNET_MULTILEVEL_LOOKUP=0</EnvVars>
88
</PropertyGroup>
99
<Target Name="Record">
10-
<Error Condition=" '$(App)' != 'maui' and '$(App)' != 'maui-blazor' " Text="Please pass -p:App=maui or -p:App=maui-blazor" />
10+
<Error Condition=" '$(App)' != 'maui' and '$(App)' != 'maui-sc' and '$(App)' != 'maui-blazor' " Text="Please pass -p:App=maui, -p:App=maui-sc, or -p:App=maui-blazor" />
1111
<RemoveDir Directories="$(Intermediate)" />
12-
<Exec Command="&quot;$(DotNetToolPath)&quot; new $(App) -o $(Intermediate)" EnvironmentVariables="$(EnvVars)" />
12+
<PropertyGroup Condition=" '$(App)' != 'maui-sc' ">
13+
<_TemplateName>$(App)</_TemplateName>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(App)' == 'maui-sc' ">
16+
<_TemplateName>maui</_TemplateName>
17+
<_TemplateParameters>-sc</_TemplateParameters>
18+
</PropertyGroup>
19+
<Exec Command="&quot;$(DotNetToolPath)&quot; new $(_TemplateName) $(_TemplateParameters) -o $(Intermediate)" EnvironmentVariables="$(EnvVars)" />
1320
<!-- Copy replacement files-->
1421
<ItemGroup>
1522
<_FilesToCopy Include="src/$(App)/*" />

0 commit comments

Comments
 (0)