Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[One .NET] fix libmono-profiler-aot.so recording #6680

Merged

Conversation

jonathanpeppers
Copy link
Member

@jonathanpeppers jonathanpeppers commented Jan 27, 2022

I found when I went to update the AOT profile in .NET MAUI:

https://github.com/jonathanpeppers/android-profiled-aot
dotnet/maui#4355

The profiler crashed with:

01-27 11:10:16.119 28922 28922 W monodroid: Creating public update directory: `/data/user/0/com.androidaot.MauiApp1/files/.__override__`
...
01-27 11:10:16.119 28922 28922 W monodroid: Initializing profiler with options: aot:port=9999output=/data/user/0/com.androidaot.MauiApp1/files/.__override__/profile.aotprofile
01-27 11:10:16.119 28922 28922 W monodroid: Looking for profiler init symbol 'mono_profiler_init_aot'? 0x7325b6355c
01-27 11:10:16.119 28922 28922 E mono-prof: Could not create AOT profiler output file 'output.aotprofile': Read-only file system

But the directory was writeable?

adb shell run-as com.androidaot.MauiApp1 touch files/.__override__/foo

After some digging, it turned out appending , to this line fixed the
issue:

https://github.com/xamarin/xamarin-android/blob/b7a368a27667c69117f64be81050403f2d5c8560/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Application.targets#L45

What happened was we lost a , somewhere in this commit:

f73a323

To fix this:

  1. Prepend a ,

  2. I found a way to actually enable tests for Profiled AOT in .NET 6
    by downloading binaries from my Github repo.

In enabling the ProfiledAOT category for .NET 6, I found that this
setting wasn't working:

<AndroidExtraAotOptions>--verbose</AndroidExtraAotOptions>

I updated %(_MonoAOTAssemblies.ProcessArguments) to solve this.

@jonathanpeppers
Copy link
Member Author

When I enabled the ProfiledAOT category, looks like a couple more tests need fixed up:

Should use default AOT profile
Expected: True
But was:  False

@jonathanpeppers jonathanpeppers marked this pull request as draft January 28, 2022 14:28
@jonathanpeppers jonathanpeppers force-pushed the dotnet-libmono-profiler-aot.so branch from c9cd030 to ad0a86e Compare January 28, 2022 17:12
@jonathanpeppers jonathanpeppers marked this pull request as ready for review January 28, 2022 20:36
@jonathanpeppers
Copy link
Member Author

Ah, I think I need chmod +x on this file:

 /Users/runner/Library/Android/dotnet/packs/Microsoft.Android.Sdk.Darwin/31.0.200-ci.pr.gh6680.45/tools/Xamarin.Android.Application.targets(53,5): error MSB3073: The command ""/Users/runner/work/1/a/TestRelease/01-28_18.19.42/temp/BuildBasicApplicationAndAotProfileIt/aprofutil"  -s -v -p 9069 -o "custom.aprof"" exited with code 126. [/Users/runner/work/1/a/TestRelease/01-28_18.19.42/temp/BuildBasicApplicationAndAotProfileIt/UnnamedProject.csproj]

    0 Warning(s)
    1 Error(s)

exit code 126, I think is permission related.

@jonathanpeppers jonathanpeppers force-pushed the dotnet-libmono-profiler-aot.so branch from a88d9c9 to 0564524 Compare January 31, 2022 16:59
I found when I went to update the AOT profile in .NET MAUI:

https://github.com/jonathanpeppers/android-profiled-aot
dotnet/maui#4355

The profiler crashed with:

    01-27 11:10:16.119 28922 28922 W monodroid: Creating public update directory: `/data/user/0/com.androidaot.MauiApp1/files/.__override__`
    ...
    01-27 11:10:16.119 28922 28922 W monodroid: Initializing profiler with options: aot:port=9999output=/data/user/0/com.androidaot.MauiApp1/files/.__override__/profile.aotprofile
    01-27 11:10:16.119 28922 28922 W monodroid: Looking for profiler init symbol 'mono_profiler_init_aot'? 0x7325b6355c
    01-27 11:10:16.119 28922 28922 E mono-prof: Could not create AOT profiler output file 'output.aotprofile': Read-only file system

But the directory was writeable?

    adb shell run-as com.androidaot.MauiApp1 touch files/.__override__/foo

After some digging, it turned out appending `,` to this line fixed the
issue:

https://github.com/xamarin/xamarin-android/blob/b7a368a27667c69117f64be81050403f2d5c8560/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Application.targets#L45

What happened was we lost a `,` somewhere in this commit:

dotnet@f73a323

To fix this:

1. Prepend a `,`

2. I found a way to actually enable tests for Profiled AOT in .NET 6
   by downloading binaries from my Github repo.

In enabling the `ProfiledAOT` category for .NET 6, I found that this
setting wasn't working:

    <AndroidExtraAotOptions>--verbose</AndroidExtraAotOptions>

I updated `%(_MonoAOTAssemblies.ProcessArguments)` to solve this.
@jonathanpeppers jonathanpeppers force-pushed the dotnet-libmono-profiler-aot.so branch from 0564524 to d5d5043 Compare January 31, 2022 19:45
@jonpryor jonpryor merged commit dadb377 into dotnet:main Feb 1, 2022
@jonathanpeppers jonathanpeppers deleted the dotnet-libmono-profiler-aot.so branch February 1, 2022 15:39
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants