Mobile Development 14 min read

Perfetto: Android Performance Tracing Tool – Concepts, Usage, and Analysis

This article introduces Perfetto, the Android platform‑level tracing tool, explains its architecture and data sources, details how to record and import trace files, demonstrates analysis features such as slice, counter and lock‑contention views, provides SQL query examples, and shares practical troubleshooting cases for mobile developers.

Sohu Tech Products
Sohu Tech Products
Sohu Tech Products
Perfetto: Android Performance Tracing Tool – Concepts, Usage, and Analysis

Perfetto is a platform‑level tracing tool introduced in Android 10 that provides a superset of data sources compared to Systrace, allowing binary protobuf‑encoded trace records to be captured for CPU, battery, system calls, memory allocation, and more. It includes built‑in analysis utilities and a web UI for visualizing traces.

Advantages include powerful functionality, high efficiency, and strong reliability. Disadvantages are its Android‑only focus, a steep learning curve requiring knowledge of ADB, Python, LLM, and C++, limited configurability, and lack of built‑in comparison features.

The tool supports system‑wide analysis on Linux and Android, capturing high‑frequency ftrace data, CPU scheduling, and thread states. Application tracing can convert Perfetto traces to other formats using raceconv , and the UI ( https://ui.perfetto.dev ) offers interactive flame graphs and timeline views.

To record a trace on a device, enable "System Trace" in Developer Options, select categories, start and stop recording via the UI, and retrieve the .perfetto-trace file from /data/local/traces or /data/misc . The trace can also be captured via command line, e.g., adb shell perfetto gfx input view wm am ss sched freq idle -o /data/misc/perfetto-traces/trace -t 10s .

Large trace files (>1 GB) may require the trace_processor binary (downloadable from https://get.perfetto.dev/trace_processor ) to preprocess traces before loading into the UI. The processor provides a SQL interface for querying trace data.

Common SQL queries include listing the longest doFrame slices, filtering by process name, calculating running time of slices using the thread_state table, and analyzing lock contention. Results appear in a table; clicking a row jumps to the corresponding slice in the timeline.

Practical examples demonstrate using Perfetto to diagnose UI freezes in a video app on foldable devices, identifying costly onBindView calls and excessive view refreshes, and resolving the issue by optimizing XML layout handling.

References to official documentation and community tutorials are provided for further reading.

mobile developmentperformance analysisperfettoAndroid Tracingsystem profiling
Sohu Tech Products
Written by

Sohu Tech Products

A knowledge-sharing platform for Sohu's technology products. As a leading Chinese internet brand with media, video, search, and gaming services and over 700 million users, Sohu continuously drives tech innovation and practice. We’ll share practical insights and tech news here.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.