Repository navigation
Description
This feature in Xamarin.Android is also known as "Startup Tracing":
https://devblogs.microsoft.com/xamarin/faster-android-startup-times-with-startup-tracing/
Yet another name for this might be "profile guided optimization".
For .NET 6, we'd like users be able to do something like the following in Release builds:
<RunAOTCompilation>true</RunAOTCompilation>
<UseProfiledAOT>true</UseProfiledAOT>This would use a built-in profile that the Android workload provides as well as the .NET MAUI workload. Recording a custom profile for a developer's app is probably not something we need in .NET 6. However, the Android & .NET MAUI teams would need to be able to record profiles. .NET MAUI's startup path is still quite a bit in flux, so ideally we would be automate the creation of the built-in MAUI profile.
There are a few pieces missing from dotnet/runtime at the moment:
libmono-profiler-aot.soaprofutilMonoAOTCompiler.AotProfilePathonly accepts 1 value:
runtime/src/tasks/AotCompilerTask/MonoAOTCompiler.cs
Lines 111 to 114 in ce3447c
| /// <summary> | |
| /// File to use for profile-guided optimization, *only* the methods described in the file will be AOT compiled. | |
| /// </summary> | |
| public string? AotProfilePath { get; set; } |
For .NET 6, I think we can take a simple approach:
- Build & ship
libmono-profiler-aot.soin the Android runtime packs. - The Android workload can ship a
aprofutilfrom mono/mono. We can emit warnings that mention recording custom AOT profiles is an experimental feature. - We can emit
profile-only,profile=foo.aproffor%(AotArguments)in the Android MSBuild targets until there is a different way.
These would get us by for now.
In the long run, recording custom AOT profiles might be something that dotnet-trace / diagnostics should support.
Activity
akoeplinger commentedon Aug 6, 2021
So we need to do two things:
libmono-profiler-aot.soin mono.proj (it's already done for Browser)AotProfilePathin MonoAOTCompiler - done in [MonoAOTCompiler] accept more than one AotProfilePath #57111[One .NET] Profiled AOT support
[MonoAOTCompiler] accept more than one AotProfilePath
steveisok commentedon Aug 10, 2021
I'm assuming we would want to include this file in the aot pack, correct?
jonathanpeppers commentedon Aug 10, 2021
@steveisok it could got in the AOT pack, but you would need an item group like this:
runtime/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.MonoCrossAOT.Sdk.props.in
Lines 2 to 4 in 57bfe47
Then the Android workload could include this file in apps when needed.
5 remaining items
jonathanpeppers commentedon Aug 13, 2021
I got
libmono-profiler-aot.soadded to theMicrosoft.NETCore.App.Runtime.AOT.[host-rid].Cross.[target-rid]packs, and added a new item group for its path.But the problem is these packs are only imported when
$(RunAOTCompilation)is true:runtime/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets.in
Lines 20 to 25 in 6fca5a5
When users record a profile, they won't be using AOT. Generally you just run a Debug build to record a profile, and
$(RunAOTCompilation)would be blank.Should I add this file to the runtime packs instead? And I would add something to exclude it in the Android workload for most builds? Similar to a Mono component, I guess?
[One .NET] Profiled AOT support
[One .NET] Profiled AOT support
[android] build and ship libmono-profiler-aot.so
[One .NET] Profiled AOT support
steveisok commentedon Sep 27, 2021
Moving the milestone to .NET 7 as we plan on trying to streamline w/ diagnostics.
Bump to dotnet/installer@c7afae69 7.0.100-preview.4.22174.1 (#6598)
steveisok commentedon Aug 2, 2022
In .NET 7, with #70194, #70851, and #68571, we have a replacement for
libmono-profiler-aot.soandaprofutil.