From 0153c2ceeaaa80b0dacb2f5f840ee1bf5f541f32 Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Mon, 20 Jan 2020 02:41:16 +0100 Subject: [PATCH] [Documentation] Update the AOT profiling part (#4137) Describe the simplyfied usage with the new targets. --- Documentation/guides/profiling.md | 65 +++++++++++++++++-------------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/Documentation/guides/profiling.md b/Documentation/guides/profiling.md index d0d0d0a0d54..d9945fe7be6 100644 --- a/Documentation/guides/profiling.md +++ b/Documentation/guides/profiling.md @@ -116,45 +116,50 @@ call][managed_timing] or [this native call][native_timing]. ## Profiling the AOT Compiler -The application needs to be built with embedded AOT profiler. That can -be done by using `AndroidEmbedProfilers` property, like: +The application needs to be built with embedded AOT profiler, the +profiler needs to be enabled and the application run on device or +emulator. That can be done by using `BuildAndStartAotProfiling` +target: - > msbuild /p:AndroidEmbedProfilers=aot /t:Install + > msbuild /t:BuildAndStartAotProfiling -Before running the application, run the `adb` command to enable the -profiler: +Related to that target is `$(AndroidAotProfilerPort)` property, which can +be used to choose the socket port number for communication with the +profiler. The default value is 9999. - > adb shell setprop debug.mono.profile aot:port=9999 +Once the application starts, the `FinishAotProfiling` target can be +used to collect the profile from the device or emulator: -The AOT profiler maps which methods are JIT'ed during runtime. Once -you get to the point in time, where you would like to get the profile -file, run `aprofutil` tool like this: + > msbuild /t:FinishAotProfiling - > aprofutil -s -v -f -p 9999 -o myprofile.aprof +The `FinishAotProfiling` target uses the `$(AndroidAotProfilerPort)` for +socket port number and `$(AndroidAotCustomProfilePath)` for the newly +created profile file, the default value is `custom.aprof`. -It collects the AOT profile from the device, through the forwarded tcp -port 9999, and writes it to the `myprofile.aprof` file. The output -should look like this: - - Calling 'adb forward tcp:9999 tcp:9999'... - Reading from '127.0.0.1:9999'... - Read total 94903 bytes... - Summary: - Modules: 6 - Types: 262 - Methods: 1,162 - Going to write the profile to 'myprofile.aprof' +The profile can be used to build your app with AOT profile. Add it to +the `@(AndroidAotProfile)` item group in your `.csproj` file and set the +`$(AndroidEnableProfiledAot)` property to `true`. You might also disable +the default AOT profile with `$(AndroidUseDefaultAotProfile)` +property. Part of your `.csproj` file might look like: + +```xml + + + + + true + false + +``` -The `aprofutil` can be also used to inspect or filter the `.aprof` -file. +The profile itself can be inspected and optionally filtered by the +[`aprofutil`][aprofutil] tool. -The profile can be used to build your app with AOT profile. Add it to -the `AndroidAotProfile` item group in your csproj and set the -`AndroidEnableProfiledAot` property to `true`. +[aprofutil]: https://github.com/mono/mono/blob/2019-10/mcs/tools/aprofutil/README.md -It is useful for scenarios like speeding up the startup of your -application or other performance critical parts, by selectively -AOT'ing only the methods included in the profile. +Using the AOT profile is useful for scenarios like speeding up the +startup of your application or other performance critical parts, by +selectively AOT'ing only the methods included in the profile. ## Profiling the JIT Compiler