tree: ea8ad1c25c40e477eacbf37b1a0adac115de0899 [path history] [tgz]
  1. binder/
  2. libprofcollectd/
  3. Android.bp
  9. profcollectd.rc


Profcollect is a system daemon that facilitates sampling profile collection and reporting for native platform applications.

Profcollect can only be enabled on userdebug or eng builds.

Supported Platforms

Currently Profcollect only supports collecting profiles from Coresight ETM enabled ARM devices.

Instructions to enable Coresight ETM can be found from the simpleperf manual.


Profcollect has two components: profcollectd, the system daemon, and profcollectctl, the command line interface.


profcollectd can be started from adb directly (under root), or automatically on system boot by setting system property through:

adb shell device_config put profcollect_native_boot enabled true

Profcollect collects profiles periodically, as well as through triggers like app launch events. Only a percentage of these events result in a profile collection to avoid using too much resource, these are controlled by the following configurations:

App launchapplaunch_trace_freq

Setting the frequency value to 0 disables collection for the corresponding event.


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



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/

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 to generate Clang PGO profiles:

create_llvm_prof \
    --profiler text \
    --binary=${BINARY_PATH} \
    --profile=${INPUT_FILE_NAME} \

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).