summaryrefslogtreecommitdiff
path: root/profcollectd
diff options
context:
space:
mode:
authorYi Kong <yikong@google.com>2021-08-16 16:30:56 +0800
committerYi Kong <yikong@google.com>2021-08-17 07:54:00 +0000
commite0880bddcd153037fbfe01403e845444c67f595a (patch)
tree8a580c27feffffb8d425dd48973503eaf6106e9f /profcollectd
parent1265cc902d0d8cdaa5a8f964510de04cc5c32362 (diff)
downloadextras-e0880bddcd153037fbfe01403e845444c67f595a.tar.gz
profcollect: Docs for processing traces
Test: N/A Change-Id: I9c932e0d87b5f378d16ae100fa37365fe1b625ed
Diffstat (limited to 'profcollectd')
-rw-r--r--profcollectd/README.md71
1 files changed, 70 insertions, 1 deletions
diff --git a/profcollectd/README.md b/profcollectd/README.md
index a0ce4024..dba75a2c 100644
--- a/profcollectd/README.md
+++ b/profcollectd/README.md
@@ -5,7 +5,7 @@ platform applications.
Profcollect can only be enabled on `userdebug` or `eng` builds.
-## Supported platforms
+## Supported Platforms
Currently Profcollect only supports collecting profiles from Coresight ETM enabled ARM devices.
@@ -32,10 +32,79 @@ are controlled by the following configurations:
| Event | Config |
|------------|------------------------|
+| Periodic | collection\_interval |
| App launch | applaunch\_trace\_freq |
Setting the frequency value to `0` disables collection for the corresponding event.
+### Processing
+
+The raw tracing data needs to be combined with the original binary to create the AutoFDO branch
+list. This is a costly process, thus it is done separately from the profile collection. Profcollect
+attempts to process all the traces when the device is idle and connected to a power supply. It can
+also be initiated by running:
+
+```
+adb shell profcollectctl process
+```
+
### Reporting
+#### Manual
+
+After actively using the device for a period of time, the device should have gathered enough data to
+generate a good quality PGO profile that represents typical system usage. Run the following command
+to create a profile report:
+
+```
+$ adb shell profcollectctl report
+Creating profile report
+Report created at: 12345678-0000-abcd-8000-12345678abcd
+```
+
+You can then fetch the report by running (under root):
+
+```
+adb pull /data/misc/profcollectd/report/12345678-0000-abcd-8000-12345678abcd.zip
+```
+
+#### Automated Uploading to Server
+
*In development*
+
+### Post Processing
+
+For each trace file, run:
+
+```
+simpleperf inject \
+ -i {TRACE_FILE_NAME} \
+ -o {OUTPUT_FILE_NAME}.data \
+ --binary {BINARY_NAME} \
+ --symdir out/target/product/{PRODUCT_NAME}/symbols
+```
+
+Afterwards, run [AutoFDO](https://github.com/google/autofdo) to generate Clang PGO profiles:
+
+```
+create_llvm_prof \
+ --profiler text \
+ --binary=${BINARY_PATH} \
+ --profile=${INPUT_FILE_NAME} \
+ --out={OUTPUT_FILE_NAME}.profdata
+```
+
+Finally, merge all the PGO profiles into one profile:
+
+```
+find {INPUT_DIR} -name *.profdata > proflist
+prebuilts/clang/host/linux-x86/llvm-binutils-stable/llvm-profdata merge \
+ --binary \
+ --sample \
+ --input-files proflist \
+ --output merged.profdata
+```
+
+More profile data usually generates better quality profiles. You may combine data from multiple
+devices running the same build to improve profile quality, and/or reduce the performance impact for
+each device (by reducing collection frequency).