MAUIverse MAUIverse

Creating a PGO Startup Profile for .NET 11 Android Apps

With CoreCLR on Android, ReadyToRun compiles startup code ahead of time, and in .NET 11 you can supply the profile it uses. MAUI includes its own startup traces, but they’re aimed at apps using the MAUI UI framework. Tomasz Cielecki points out that if you’re running Android XML layouts, Avalonia, Uno or MvvmCross, or if you just want a profile that matches your own app, recording one yourself makes sense. In his apps, a custom profile also shaved off a lot of the extra size he saw moving from Mono to CoreCLR.

The workflow is short. Install the maui dotnet tool, then add the Microsoft.Maui.ProfilingHelper package to apps that don’t use the MAUI UI framework and call MauiProfilingMarker.Complete(); once startup finishes, for example in MainActivity.OnCreate(). Running maui profile startup builds a Release app, launches it on a device or emulator and writes a .mibc file, which you reference from your project through _ReadyToRunPgoFiles. He includes the command-line output, plus a warning to look for if the app doesn’t connect to the profiling channel.

The post also shows how to turn the companion .nettrace file into a Speedscope flame graph with dotnet-trace. In his example, that graph shows dependency injection resolution taking time before MainActivity runs. It’s a good follow-up to his earlier .NET 11 readiness post if you care about startup.

View Source →

← Back to Community Feed

}