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.so
aprofutil
MonoAOTCompiler.AotProfilePath
only accepts 1 value:
runtime/src/tasks/AotCompilerTask/MonoAOTCompiler.cs
Lines 111 to 114 in ce3447c
For .NET 6, I think we can take a simple approach:
- Build & ship
libmono-profiler-aot.so
in the Android runtime packs. - The Android workload can ship a
aprofutil
from mono/mono. We can emit warnings that mention recording custom AOT profiles is an experimental feature. - We can emit
profile-only,profile=foo.aprof
for%(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.