Skip to content

Support for Android "Profiled AOT" in .NET 6 #56989

Closed
@jonathanpeppers

Description

@jonathanpeppers

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:

  1. libmono-profiler-aot.so
  2. aprofutil
  3. MonoAOTCompiler.AotProfilePath only accepts 1 value:

/// <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:

  1. Build & ship libmono-profiler-aot.so in the Android runtime packs.
  2. The Android workload can ship a aprofutil from mono/mono. We can emit warnings that mention recording custom AOT profiles is an experimental feature.
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions