Files
TheRock/rocm-systems/projects/rocprofiler-systems/external/perfetto/docs/case-studies/android-boot-tracing.md
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

2.6 KiB

Recording traces on Android boot

Since Android 13 (T), perfetto can be configured to automatically start recording traces on boot. This can be useful to profile the boot process.

Steps

  • Create a file with the desired trace configuration in Text format (not binary). Example (more in /test/configs/):
    # One buffer allocated within the central tracing binary for the entire trace,
    # shared by the two data sources below.
    buffers {
      size_kb: 32768
      fill_policy: DISCARD
    }
    
    # Ftrace data from the kernel, mainly the process scheduling events.
    data_sources {
      config {
        name: "linux.ftrace"
        target_buffer: 0
        ftrace_config {
          ftrace_events: "sched_switch"
          ftrace_events: "sched_waking"
          ftrace_events: "sched_wakeup_new"
    
          ftrace_events: "task_newtask"
          ftrace_events: "task_rename"
    
          ftrace_events: "sched_process_exec"
          ftrace_events: "sched_process_exit"
          ftrace_events: "sched_process_fork"
          ftrace_events: "sched_process_free"
          ftrace_events: "sched_process_hang"
          ftrace_events: "sched_process_wait"
        }
      }
    }
    
    # Resolve process commandlines and parent/child relationships, to better
    # interpret the ftrace events, which are in terms of pids.
    data_sources {
      config {
        name: "linux.process_stats"
        target_buffer: 0
      }
    }
    
    # 10s trace, but can be stopped prematurely via `adb shell pkill -u perfetto`.
    duration_ms: 10000
    
  • Put the file on the device at /data/misc/perfetto-configs/boottrace.pbtxt:
    adb push <yourfile> /data/misc/perfetto-configs/boottrace.pbtxt
    
  • Enable the perfetto_trace_on_boot service:
    adb shell setprop persist.debug.perfetto.boottrace 1
    
    The property is reset on boot. In order to trace the next boot, the command must be reissued.
  • Reboot the device.
  • The output trace will be written at /data/misc/perfetto-traces/boottrace.perfetto-trace. The file will be removed before a new trace is started.
    adb pull /data/misc/perfetto-traces/boottrace.perfetto-trace
    
    N.B.: The file will appear after the recording has stopped (be sure to set duration_ms to a reasonable value in the config) or after the first flush_period_ms.
  • boottrace.perfetto-trace can now be opened in ui.perfetto.dev

Implementation details

  • The trace will start only after persistent properties are loaded, which happens after /data has been mounted.
  • The command to start the trace is implemented as oneshot init service.