Convert Figma logo to code with AI

google logoperfetto

Production-grade client-side tracing, profiling, and analysis for complex software systems.

4,162
498
4,162
111

Top Related Projects

Performance analysis tools based on Linux perf_events (aka perf) and ftrace

Deprecated Catapult GitHub. Please instead use http://crbug.com "Speed>Benchmarks" component for bugs and https://chromium.googlesource.com/catapult for downloading and editing source code..

PerfView is a CPU and memory performance-analysis tool

3,572

Vector is an on-host performance monitoring framework which exposes hand picked high resolution metrics to every engineer’s browser.

4,285

C/C++ Performance Profiler

Quick Overview

Perfetto is an open-source system profiling, app tracing, and trace analysis platform developed by Google. It provides a comprehensive set of tools for performance analysis across various platforms, including Android, Linux, and Chrome OS. Perfetto aims to offer a unified solution for capturing, storing, and analyzing performance data.

Pros

  • Cross-platform support (Android, Linux, Chrome OS)
  • Highly efficient and low-overhead tracing
  • Extensible architecture with custom data sources
  • Powerful web-based trace viewer for analysis

Cons

  • Steep learning curve for advanced usage
  • Limited documentation for some features
  • Primarily focused on Google-related platforms
  • May require root access for certain tracing features

Code Examples

  1. Initializing a Perfetto tracing session:
#include "perfetto/tracing.h"

void InitializeTracing() {
  perfetto::TracingInitArgs args;
  args.backends = perfetto::kSystemBackend;
  perfetto::Tracing::Initialize(args);
}
  1. Adding a track event to the trace:
TRACE_EVENT_BEGIN("category", "EventName");
// ... code to be measured ...
TRACE_EVENT_END("category");
  1. Creating a custom data source:
class MyDataSource : public perfetto::DataSource<MyDataSource> {
 public:
  void OnSetup(const SetupArgs&) override {}
  void OnStart(const StartArgs&) override {}
  void OnStop(const StopArgs&) override {}
};

PERFETTO_DECLARE_DATA_SOURCE_STATIC_MEMBERS(MyDataSource);
PERFETTO_REGISTER_DATA_SOURCE(MyDataSource);

Getting Started

To start using Perfetto in your project:

  1. Include Perfetto in your build system (e.g., via CMake or Bazel).
  2. Initialize tracing in your application:
#include "perfetto/tracing.h"

int main() {
  perfetto::TracingInitArgs args;
  args.backends = perfetto::kInProcessBackend;
  perfetto::Tracing::Initialize(args);

  perfetto::TrackEvent::Register();

  // Your application code here
  TRACE_EVENT_BEGIN("app", "MainLoop");
  // ...
  TRACE_EVENT_END("app");

  return 0;
}
  1. Build and run your application with Perfetto tracing enabled.
  2. Use the Perfetto trace viewer (https://ui.perfetto.dev/) to analyze the captured traces.

Competitor Comparisons

Performance analysis tools based on Linux perf_events (aka perf) and ftrace

Pros of perf-tools

  • Lightweight and easy to use, with minimal setup required
  • Focuses on Linux performance analysis tools, making it ideal for Linux-specific debugging
  • Provides a collection of individual scripts, allowing users to pick and choose tools as needed

Cons of perf-tools

  • Limited cross-platform support compared to Perfetto's broader compatibility
  • Less comprehensive data visualization and analysis capabilities
  • Lacks the advanced tracing and profiling features offered by Perfetto

Code Comparison

perf-tools (execsnoop):

#!/bin/bash
# Trace new processes with arguments
stdbuf -oL perf script -F comm,pid,ppid,args | \
    awk '$1 != "-" && $1 != "perf" {print}'

Perfetto (trace config):

TraceConfig config;
config.add_buffers()->set_size_kb(1024);
auto* ds = config.add_data_sources()->mutable_config();
ds->set_name("linux.ftrace");
ds->set_target_buffer(0);

Both repositories provide valuable performance analysis tools, but they cater to different use cases. perf-tools offers a collection of lightweight, Linux-specific scripts for quick debugging, while Perfetto provides a more comprehensive, cross-platform tracing and profiling solution with advanced visualization capabilities.

Deprecated Catapult GitHub. Please instead use http://crbug.com "Speed>Benchmarks" component for bugs and https://chromium.googlesource.com/catapult for downloading and editing source code..

Pros of Catapult

  • More comprehensive suite of web performance tools, including Telemetry and Trace-Viewer
  • Longer history and established ecosystem within the Chromium project
  • Supports a wider range of performance analysis scenarios beyond tracing

Cons of Catapult

  • Larger and more complex codebase, potentially harder to maintain
  • Less focus on efficient, low-overhead tracing compared to Perfetto
  • May have slower adoption of new features due to its broader scope

Code Comparison

Catapult (Python-based):

from telemetry import story
from telemetry.page import page as page_module

class MyStorySet(story.StorySet):
    def __init__(self):
        super(MyStorySet, self).__init__()
        self.AddStory(page_module.Page('http://www.google.com', self, name='Google'))

Perfetto (C++-based):

#include "perfetto/tracing.h"

PERFETTO_DEFINE_CATEGORIES(perfetto::Category("rendering").SetDescription("Rendering events"));

void MyTracingFunction() {
    TRACE_EVENT("rendering", "Frame");
}

The code snippets showcase the different approaches: Catapult focuses on web performance testing with Python, while Perfetto provides low-level C++ tracing APIs for efficient system-wide profiling.

PerfView is a CPU and memory performance-analysis tool

Pros of PerfView

  • Specifically designed for .NET and Windows performance analysis
  • Includes a rich GUI for data visualization and analysis
  • Offers extensive documentation and tutorials for users

Cons of PerfView

  • Limited cross-platform support compared to Perfetto
  • Less flexible for custom data sources and trace formats
  • Primarily focused on Windows ecosystem, limiting its use in other environments

Code Comparison

PerfView (C#):

TraceEventSession session = new TraceEventSession("MySession");
session.EnableProvider("Microsoft-Windows-DotNETRuntime");
session.Source.Dynamic.All += (TraceEvent data) => {
    Console.WriteLine($"Got Event {data.EventName}");
};

Perfetto (C++):

perfetto::TracingInitArgs args;
perfetto::Tracing::Initialize(args);
auto* tracing_session = perfetto::Tracing::NewTrace();
tracing_session->Setup(config);
tracing_session->Start();

Both tools provide APIs for setting up tracing sessions, but PerfView is more focused on .NET-specific providers, while Perfetto offers a more generic approach suitable for various platforms and data sources.

3,572

Vector is an on-host performance monitoring framework which exposes hand picked high resolution metrics to every engineer’s browser.

Pros of Vector

  • Designed specifically for high-performance service-to-service networking
  • Focuses on observability and telemetry for cloud-native environments
  • Supports a wide range of data sources and sinks

Cons of Vector

  • Less comprehensive tracing capabilities compared to Perfetto
  • May have a steeper learning curve for users not familiar with cloud-native observability concepts
  • Limited support for low-level system tracing

Code Comparison

Vector configuration example:

[sources.http_server]
type = "http_server"
address = "0.0.0.0:80"

[sinks.console]
type = "console"
inputs = ["http_server"]
encoding.codec = "json"

Perfetto configuration example:

buffers {
  size_kb: 63488
  fill_policy: DISCARD
}
data_sources {
  config {
    name: "linux.process_stats"
    target_buffer: 0
    process_stats_config {
      proc_stats_poll_ms: 1000
    }
  }
}

Vector is more focused on configuring data pipelines for observability, while Perfetto's configuration is geared towards detailed system tracing and performance analysis. Both projects serve different primary use cases, with Vector excelling in cloud-native environments and Perfetto providing deeper insights into system-level performance.

4,285

C/C++ Performance Profiler

Pros of Orbit

  • More focused on game and graphics profiling, with features tailored for GPU profiling and frame analysis
  • Offers a user-friendly GUI for easier data visualization and interaction
  • Supports live profiling and real-time data collection

Cons of Orbit

  • Limited to Windows and Linux platforms, lacking macOS support
  • Narrower scope compared to Perfetto's system-wide tracing capabilities
  • Less extensive documentation and community resources

Code Comparison

Orbit (C++):

void OrbitApp::SelectCallstackEvents(
    const std::vector<CallstackEvent>& selected_callstack_events) {
  selected_callstack_events_ = selected_callstack_events;
  UpdateSelectionReport();
}

Perfetto (C++):

void TraceProcessor::EnableMetatrace() {
  metatrace::Enable();
  metatrace_id_ = metatrace::InternString("TraceProcessor::EnableMetatrace");
}

Both projects use C++ and demonstrate object-oriented programming. Orbit's code focuses on UI-related functionality, while Perfetto's example shows low-level tracing operations. Perfetto's codebase is generally more extensive and covers a broader range of tracing scenarios.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Perfetto - System profiling, app tracing and trace analysis

Perfetto is an open-source suite of SDKs, daemons and tools which use tracing to help developers understand the behaviour of complex systems and root-cause functional and performance issues on client and embedded systems.

It is a production-grade tool that is the default tracing system for the Android operating system and the Chromium browser.

Core Components

Perfetto is not a single tool, but a collection of components that work together:

  • High-performance tracing daemons: For capturing tracing information from many processes on a single machine into a unified trace file.
  • Low-overhead tracing SDK: A C++17 library for direct userspace-to-userspace tracing of timings and state changes in your application.
  • Extensive OS-level probes: For capturing system-wide context on Android and Linux (e.g. scheduling states, CPU frequencies, memory profiling, callstack sampling).
  • Browser-based UI: A powerful, fully local UI for visualizing and exploring large, multi-GB traces on a timeline. It works in all major browsers, requires no installation, and can open traces from other tools.
  • SQL-based analysis library: A powerful engine that allows you to programmatically query traces using SQL to automate analysis and extract custom metrics.

Why Use Perfetto?

Perfetto was designed to be a versatile and powerful tracing system for a wide range of use cases.

  • For Android App & Platform Developers: Debug and root-cause functional and performance issues like slow startups, dropped frames (jank), animation glitches, low memory kills, and ANRs. Profile both Java/Kotlin and native C++ memory usage with heap dumps and profiles.
  • For C/C++ Developers (Linux, macOS, Windows): Use the Tracing SDK to instrument your application with custom trace points to understand its execution flow, find performance bottlenecks, and debug complex behavior. On Linux, you can also perform detailed CPU and native heap profiling.
  • For Linux Kernel & System Developers: Get deep insights into kernel behavior. Perfetto acts as an efficient userspace daemon for ftrace, allowing you to visualize scheduling, syscalls, interrupts, and custom kernel tracepoints on a timeline.
  • For Chromium Developers: Perfetto is the tracing backend for chrome://tracing. Use it to debug and root-cause issues in the browser, V8, and Blink.
  • For Performance Engineers & SREs: Analyze and visualize a wide range of profiling and tracing formats, not just Perfetto's. Use the powerful SQL interface to programmatically analyze traces from tools like Linux perf, macOS Instruments, Chrome JSON traces, and more.

Getting Started

We've designed our documentation to guide you to the right information as quickly as possible, whether you're a newcomer to performance analysis or an experienced developer.

  1. New to tracing? If you're unfamiliar with concepts like tracing and profiling, start here:

    • What is Tracing? - A gentle introduction to the world of performance analysis.
  2. Ready to dive in? Our "Getting Started" guide is the main entry point for all users. It will help you find the right tutorials and documentation for your specific needs:

  3. Want the full overview? For a comprehensive look at what Perfetto is, why it's useful, and who uses it, see our main documentation page:

Community & Support

Have questions? Need help?

We follow Google's Open Source Community Guidelines.