How do I start using Perfetto?

TIP: If you are unfamiliar with the word "tracing" or in general, are new to the world of performance, we suggest reading the What is Tracing? page first. If you are not quite sure what Perfetto is and why it's useful, check out the Perfetto homepage first.

Perfetto is a large project and it can be daunting for someone new to undestand what parts of the documentation relevant to them. By focusing on what technology you are using and what you are trying to accomplish, this page will guide you through our documentation and help you solve problems with Perfetto as quickly as possible.

Our docs make use of the terms "Tutorials", "Cookbooks" and "Case Studies":

Based on what technology you are interested in, please choose one of the following sections to go next:

graph TD A[Start here] --> B{What is your role?}; B --> C["Android App/Platform Developer"]; B --> D["Linux Kernel Developer"]; B --> E["C/C++ Developer (non-Android)"]; B --> F["Chromium Developer"]; B --> G["I have trace-like data"]; B --> H["None of the above"];

Android App & Platform Developers

graph TD A[Android App & Platform Developers] --> B{What is your goal?}; B --> C["Understand system behavior / debug functional issues"]; B --> D["Optimize performance / address latency"]; B --> E["Diagnose memory issues"];

Perfetto is the default tracing system on Android. It provides a powerful way to understand the intricate workings of the Android OS and applications, enabling developers to diagnose not only performance bottlenecks but also complex functional issues and unexpected behaviors. By capturing a detailed, chronological record of system and application activity, Perfetto helps you see how different components interact over time.

If you are a developer working on an Android app or on Android platform code (i.e. the Android OS itself), Perfetto can help you answer a wide array of questions:

  1. Why is a specific operation taking longer than expected?
  2. What sequence of events led to this bug?
  3. How do different processes and system services interact during a particular use case?
  4. Is my component behaving correctly under specific system conditions?
  5. Why is my app - or the whole system - using so much memory?
  6. How can I optimize my component's CPU or resource usage?
  7. What is the state of various system components at a critical point in time?

As an Android App Developer, you might already be using Perfetto via one of the app-focused tools which use Perfetto under the hood. Examples include:

These projects use Perfetto trace tooling under the hoods to expose a more polished and curated experience to app developers. On the other hand, they tend to expose a reduced set of features to favour ease of use and reduce cognitive overwhelming.

If you are just getting started with app tracing you should likely look first into the aforementioned tools, as they offer a smoother learning curve. If, on the other hand, you want to use the full set of features, and accept the cost of dealing with a larger complexity and expertise demand, you can use Perfetto directly and take advantage of its bleeding edge features.

This guide, and the rest of these docs, can help you start using Perfetto to gain deeper insights into your app's behavior and its interaction with the Android system.

As a Google Platform Developer, Perfetto is deeply integrated throughout the whole development process for Android platform changes. Platform developers can (links are for Googlers only):

  • Collect Perfetto traces locally while developing features or fixing bugs
  • Collect, analyse and visualize Perfetto traces in Android lab tests
  • Collect, analyse and visualize Perfetto traces from Android field telemetry systems

The below guidance can help you understand the range of low-level tooling Perfetto makes available for comprehensive system analysis and debugging.

Many OEMs and partners also have equivalent to the above local/lab/field systems inside their own companies: please consult your internal company documentation for details on this.

The below guidance can help you understand the range of low-level tooling Perfetto makes available for comprehensive system analysis and debugging.

Understanding System Behavior & Debugging Functional Issues

When you need to understand how different parts of the system interact, debug a complex functional bug, or see the sequence of events leading to an unexpected state, Perfetto provides powerful insights.

Optimizing Performance & Addressing Latency

When a component is slow, exhibits jank, or critical operations take too long, Perfetto provides the tools to investigate. This can involve direct CPU/GPU work, but often on Android, latency stems from inter-process communication (IPC) like Binder, lock contention, I/O waits, or inefficient scheduling. For issues primarily related to memory consumption, see the "Diagnosing Memory Issues" section below.

Diagnosing Memory Issues

High memory usage can lead to poor performance, increased garbage collection pauses (for Java/Kotlin), and even apps or services being killed by the Low Memory Killer (LMK). For a comprehensive approach to these problems, start with our detailed case study:

Perfetto also provides specific tools to investigate and attribute memory usage:

Linux Kernel Developer

Perfetto offers deep integration with the Linux kernel, providing powerful tools for kernel developers to understand system behavior, debug issues, and optimize performance. It interfaces with:

Here's how Perfetto can assist Linux kernel development and debugging:

C/C++ Developer (non-Android)

If you're developing C/C++ applications on Linux, macOS, or Windows, Perfetto's Tracing SDK allows you to instrument your code to understand its behavior and identify performance characteristics. On Linux, Perfetto also offers dedicated heap and CPU profiling tools for deeper investigation into resource usage.

Here’s how Perfetto can help:

Chromium Developers

Perfetto underpins the chrome://tracing system for the Chromium browser and its related projects (Angle, Skia, V8). While the Chromium project has its own extensive internal documentation and best practices for recording and analyzing traces, Perfetto provides the foundational tools for this.

If you're looking to capture traces from Chrome, our tutorial provides a straightforward way to get started using the Perfetto UI:

For a general introduction to practical trace analysis in Chrome, this Perf-Planet blog post is also a helpful resource.

Anyone with "trace-like" data to analyse/visualize

Perfetto's powerful UI and Trace Processor are not limited to traces recorded by Perfetto itself. If you have existing traces from other systems or custom timestamped data, you can often leverage Perfetto for visualization and analysis.

Anyone not listed above

If your specific role or use case wasn't directly covered by the categories above, don't worry! Perfetto is a versatile suite of tools, and its core capabilities might still be highly relevant to your needs. At its heart, Perfetto excels in several key areas:

  1. Recording Rich Timeline Data: Perfetto provides a reasonably high-performance Tracing SDK and integrates deeply with system-level data sources (like ftrace on Linux/Android). This allows you to capture detailed, time-correlated events from your application and/or the system it runs on.

  2. Powerful Timeline Visualization (No Code Required): The Perfetto UI is designed to intuitively explore large, complex traces. You can navigate timelines, zoom into nanosecond-level details, inspect event properties, and correlate activity across different processes and hardware components, all through a graphical interface without writing any code. Features like track filtering, expanding/collapsing process threads, and visualizing event flows help you understand what your system is doing.

    • Explore diverse data: Perfetto can open various external trace formats directly in the UI.
    • Discover UI features: The Perfetto UI also has features like Debug Tracks that allow for sophisticated data aggregation and custom visualizations driven by simple UI configurations.
  3. In-depth Programmatic Trace Analysis: For going beyond visual inspection, automating analysis, or extracting custom metrics, Perfetto's Trace Processor engine allows you to query traces using SQL. This powerful backend can be accessed programmatically.

    • Automate your insights: If you have recurring analysis tasks or want to extract specific metrics from any trace (Perfetto-native or converted), the Trace Processor is invaluable.

For further inspiration on how Perfetto's flexible architecture has been adapted for a wide range of complex diagnostic scenarios, see:

If you're unsure where to start or how Perfetto might apply to your unique situation: