Skip to content

Conversation

@jonathanpeppers
Copy link
Member

Context: e9a4c9f

Since various changes to our startup code path have gone into
xamarin-android/main, our built-in .aotprofile files are out of
date.

In following the instructions from e9a4c9f, with only two differences
that seem to be more correct:

  1. Build xamarin-android/main in Release mode.

  2. Record the profile as a Release build:

    .\bin\Release\bin\xabuild.exe -t:BuildAndStartAotProfiling -r -p:Configuration=Release -p:AndroidEmbedProfilers=aot

To test the profiles, I tested the startup times, as well as:

> adb shell setprop debug.mono.log default,timing=bare,assembly,mono_log_level=debug,mono_log_mask=aot
> adb logcat -c
# Launch the app
> adb logcat -d | grep 'AOT NOT FOUND' | code -

Manually reviewed all the AOT NOT FOUND messages to make sure they
generally made sense.

startup.aotprofile is now:

Modules:
    C148BD72-52B6-4EAF-979B-82DCAF7930A7 mscorlib
    F11B3CBC-7975-4787-94E3-EBBCD5848542 Mono.Android
    9DA65876-209F-45D1-BB03-EAC4189F47DB System
    E80DBADA-DA9E-45D8-8266-9BADDA8E4134 Java.Interop
    02BC5FE4-B6E6-49BC-BADA-41E5C154EE9C Xamarin.Google.Android.Material
    379D77C4-CF8A-4445-860B-68AF3453EB4E Xamarin.AndroidX.AppCompat
    6AF61659-5025-49B3-9422-56A118315201 Xamarin.AndroidX.Fragment
    B034FA80-29BD-4559-8354-26A743F74253 Xamarin.AndroidX.Activity
    25A01486-D791-4298-BD90-18582392EF33 Xamarin.AndroidX.Core
    D2B01D5A-B81D-4F62-80E2-C362D81D9CD9 Xamarin.Essentials
    8C81D503-BA08-4E9E-955B-8E3F46E6259D Xamarin.AndroidX.DrawerLayout
Summary:
    Modules:         11  (of 12)
    Types:          221  (of 234)
    Methods:      1,065  (of 1068)

startup-xf.aotprofile is now:

Modules:
    453BA78E-5368-4AE7-8C50-D0D000151814 mscorlib
    703E4A2E-944C-4B09-8F81-921605099A0A Mono.Android
    2D990956-2E4B-41AA-A6B5-99C1500A1BD0 System
    CC84AB0F-1B3A-4D73-9B9B-E3F01388ADDE Java.Interop
    C874A6EC-7274-48B4-85FC-061E0CAA3C72 Xamarin.Forms.Platform.Android
    540E8DC0-FDB7-4DA6-AD39-41CD65119AFB Xamarin.AndroidX.AppCompat
    426CF015-B049-4BF6-97FE-B90B14D517D3 Xamarin.AndroidX.Fragment
    E2C0D34A-DD41-46D1-85A7-E1DACA936D88 Xamarin.AndroidX.Activity
    42265161-73E9-4897-A212-EACECBCB1AA9 Xamarin.AndroidX.Core
    4DA33C24-D57E-4B0D-BF00-02D40BA1FEC6 System.Core
    59DBDF44-E8E1-41BA-B486-495AF42F1804 Xamarin.Forms.Core
    653993E2-BBDB-407A-99EE-0325524076F4 Xamarin.Essentials
    2136C188-7A4D-4300-8CE3-39A4282FDE7C Xamarin.Forms.Platform
    B2FBD056-FB8F-4E99-A1F1-5E7DFE39D799 Xamarin.Forms.Xaml
    3400FFAB-1BEE-4003-8C91-EE8E71FA17C5 Xamarin.AndroidX.DrawerLayout
    E9F428A6-B0BA-4B06-B101-0C60A0DD9ED1 Xamarin.Google.Android.Material
    2A7497E5-BCDC-4C4F-A2C5-76249090766E Xamarin.AndroidX.CoordinatorLayout
    705E81AC-7EF5-413F-897C-3B0798C49B31 Xamarin.AndroidX.RecyclerView
    05E2BE3F-F436-4F2A-98A7-FAEDBB38FC72 Xamarin.AndroidX.ViewPager
    050B9CC1-E939-4856-B3F4-47DF20C96E27 FormsViewGroup
    45B33167-3CA9-4DBD-BF22-8A279857262D Xamarin.AndroidX.AppCompat.AppCompatResources
    E824DB2F-7D54-4F4C-A158-6C8F8EDA44CF Xamarin.AndroidX.SwipeRefreshLayout
Summary:
    Modules:         22  (of 24)
    Types:        1,249  (of 1364)
    Methods:      6,637  (of 6694)

dotnet.aotprofile is now:

Modules:
    B130EA94-1287-455A-B9E4-C8EF4E55A5A8 System.Private.CoreLib
    DD2F77BD-1CF1-487F-B3C2-AF9822623231 Mono.Android
    FC3BEB31-9B4E-4575-BDC0-F97AE838F8E0 Java.Interop
    A879ACC5-F09F-486B-9892-39CC89F43A94 Xamarin.Google.Android.Material
    432229CF-2D35-464B-9077-D159CF135911 Xamarin.AndroidX.AppCompat
    FB29D83D-E8DC-41A9-8089-32FABA6034C6 Xamarin.AndroidX.Fragment
    1CBFBDDF-4949-467E-92FC-46377D3F3452 Xamarin.AndroidX.Activity
    339EE7A0-CCFE-43B2-A619-2B748BCA2133 Xamarin.AndroidX.Core
    E8F4F5BB-8F8F-4C8E-A393-80FE30958AF6 Xamarin.AndroidX.DrawerLayout
Summary:
    Modules:          9  (of 10)
    Types:          184  (of 194)
    Methods:        798  (of 801)

Last updated in 3e699d6.

The results of using the old AOT Profiles on these projects vs the
new AOT Profile, a 10-run average, on a Pixel 5:

Template Name Old Profile Time New Profile Time
Navigation Drawer App 00:00:00.263 00:00:00.239
Xamarin.Forms Flyout 00:00:00.691 00:00:00.645
AndroidApp1* (.NET 6) 00:00:00.309 00:00:00.250
  • The .NET 6 profile is based on this project:

https://github.com/jonathanpeppers/android-profiled-aot/tree/main/AndroidApp1

A future PR like this will need to be made for dotnet/maui, but likely
closer to the next release. I suspect their startup code path will
change further.

Context: dotnet@e9a4c9f

Since various changes to our startup code path have gone into
xamarin-android/main, our built-in `.aotprofile` files are out of
date.

In following the instructions from e9a4c9f, with only two differences
that seem to be more correct:

1. Build xamarin-android/main in Release mode.

2. Record the profile as a `Release` build:

    > .\bin\Release\bin\xabuild.exe -t:BuildAndStartAotProfiling -r -p:Configuration=Release -p:AndroidEmbedProfilers=aot

To test the profiles, I tested the startup times, as well as:

    > adb shell setprop debug.mono.log default,timing=bare,assembly,mono_log_level=debug,mono_log_mask=aot
    > adb logcat -c
    # Launch the app
    > adb logcat -d | grep 'AOT NOT FOUND' | code -

Manually reviewed all the `AOT NOT FOUND` messages to make sure they
generally made sense.

`startup.aotprofile` is now:

    Modules:
        C148BD72-52B6-4EAF-979B-82DCAF7930A7 mscorlib
        F11B3CBC-7975-4787-94E3-EBBCD5848542 Mono.Android
        9DA65876-209F-45D1-BB03-EAC4189F47DB System
        E80DBADA-DA9E-45D8-8266-9BADDA8E4134 Java.Interop
        02BC5FE4-B6E6-49BC-BADA-41E5C154EE9C Xamarin.Google.Android.Material
        379D77C4-CF8A-4445-860B-68AF3453EB4E Xamarin.AndroidX.AppCompat
        6AF61659-5025-49B3-9422-56A118315201 Xamarin.AndroidX.Fragment
        B034FA80-29BD-4559-8354-26A743F74253 Xamarin.AndroidX.Activity
        25A01486-D791-4298-BD90-18582392EF33 Xamarin.AndroidX.Core
        D2B01D5A-B81D-4F62-80E2-C362D81D9CD9 Xamarin.Essentials
        8C81D503-BA08-4E9E-955B-8E3F46E6259D Xamarin.AndroidX.DrawerLayout
    Summary:
        Modules:         11  (of 12)
        Types:          221  (of 234)
        Methods:      1,065  (of 1068)

`startup-xf.aotprofile` is now:

    Modules:
        453BA78E-5368-4AE7-8C50-D0D000151814 mscorlib
        703E4A2E-944C-4B09-8F81-921605099A0A Mono.Android
        2D990956-2E4B-41AA-A6B5-99C1500A1BD0 System
        CC84AB0F-1B3A-4D73-9B9B-E3F01388ADDE Java.Interop
        C874A6EC-7274-48B4-85FC-061E0CAA3C72 Xamarin.Forms.Platform.Android
        540E8DC0-FDB7-4DA6-AD39-41CD65119AFB Xamarin.AndroidX.AppCompat
        426CF015-B049-4BF6-97FE-B90B14D517D3 Xamarin.AndroidX.Fragment
        E2C0D34A-DD41-46D1-85A7-E1DACA936D88 Xamarin.AndroidX.Activity
        42265161-73E9-4897-A212-EACECBCB1AA9 Xamarin.AndroidX.Core
        4DA33C24-D57E-4B0D-BF00-02D40BA1FEC6 System.Core
        59DBDF44-E8E1-41BA-B486-495AF42F1804 Xamarin.Forms.Core
        653993E2-BBDB-407A-99EE-0325524076F4 Xamarin.Essentials
        2136C188-7A4D-4300-8CE3-39A4282FDE7C Xamarin.Forms.Platform
        B2FBD056-FB8F-4E99-A1F1-5E7DFE39D799 Xamarin.Forms.Xaml
        3400FFAB-1BEE-4003-8C91-EE8E71FA17C5 Xamarin.AndroidX.DrawerLayout
        E9F428A6-B0BA-4B06-B101-0C60A0DD9ED1 Xamarin.Google.Android.Material
        2A7497E5-BCDC-4C4F-A2C5-76249090766E Xamarin.AndroidX.CoordinatorLayout
        705E81AC-7EF5-413F-897C-3B0798C49B31 Xamarin.AndroidX.RecyclerView
        05E2BE3F-F436-4F2A-98A7-FAEDBB38FC72 Xamarin.AndroidX.ViewPager
        050B9CC1-E939-4856-B3F4-47DF20C96E27 FormsViewGroup
        45B33167-3CA9-4DBD-BF22-8A279857262D Xamarin.AndroidX.AppCompat.AppCompatResources
        E824DB2F-7D54-4F4C-A158-6C8F8EDA44CF Xamarin.AndroidX.SwipeRefreshLayout
    Summary:
        Modules:         22  (of 24)
        Types:        1,249  (of 1364)
        Methods:      6,637  (of 6694)

`dotnet.aotprofile` is now:

    Modules:
        B130EA94-1287-455A-B9E4-C8EF4E55A5A8 System.Private.CoreLib
        DD2F77BD-1CF1-487F-B3C2-AF9822623231 Mono.Android
        FC3BEB31-9B4E-4575-BDC0-F97AE838F8E0 Java.Interop
        A879ACC5-F09F-486B-9892-39CC89F43A94 Xamarin.Google.Android.Material
        432229CF-2D35-464B-9077-D159CF135911 Xamarin.AndroidX.AppCompat
        FB29D83D-E8DC-41A9-8089-32FABA6034C6 Xamarin.AndroidX.Fragment
        1CBFBDDF-4949-467E-92FC-46377D3F3452 Xamarin.AndroidX.Activity
        339EE7A0-CCFE-43B2-A619-2B748BCA2133 Xamarin.AndroidX.Core
        E8F4F5BB-8F8F-4C8E-A393-80FE30958AF6 Xamarin.AndroidX.DrawerLayout
    Summary:
        Modules:          9  (of 10)
        Types:          184  (of 194)
        Methods:        798  (of 801)

Last updated in 3e699d6.

The results of using the old AOT Profiles on these projects vs the
new AOT Profile, a 10-run average, on a Pixel 5:

| Template Name         |  Old Profile Time | New Profile Time |
| --------------------- | ----------------: | ---------------: |
| Navigation Drawer App |      00:00:00.263 |     00:00:00.239 |
| Xamarin.Forms Flyout  |      00:00:00.691 |     00:00:00.645 |
| AndroidApp1* (.NET 6) |      00:00:00.309 |     00:00:00.250 |

* The .NET 6 profile is based on this project:

https://github.com/jonathanpeppers/android-profiled-aot/tree/main/AndroidApp1

A future PR like this will need to be made for dotnet/maui, but likely
closer to the next release. I suspect their startup code path will
change further.
@jonathanpeppers
Copy link
Member Author

Ok this seems to be a "better" profile with more methods:

233,686 Package size difference 1.34% (of 17,480,144)

I'll need to update the .apkdesc files.

Copy link
Contributor

@dellis1972 dellis1972 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok. However we have one failing test with the following warning (it expects 0 warnings)

 warning : An exception occurred while validating the Java SDK installation in '/Users/runner/Library/Android/jdk-11' that was found while searching the paths from '$JI_JAVA_HOME'. Ensure that the Android section of the Visual Studio options has a valid Java SDK directory configured. To use a custom SDK path for a command line build, set the 'JavaSdkDirectory' MSBuild property to the custom path. Exception: Not a directory (Parameter 'homePath') 

Not sure if this is new as it does not seem to be related to this PR.

@jonpryor
Copy link
Contributor

@dellis1972 wrote:

Not sure if this is new as it does not seem to be related to this PR.

I don't see similar failures on current main -- checked https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=5755972&view=results -- and I don't see how this PR could possibly cause a new warning. I'm considering the test failure to be noise.

@jonpryor jonpryor merged commit e4bd531 into dotnet:main Feb 15, 2022
@jonathanpeppers jonathanpeppers deleted the UpdateAOTProfiles branch February 15, 2022 21:46
@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.

3 participants