README.md
1 # Perfetto - Performance instrumentation and tracing
2
3 Perfetto is an open-source project for performance instrumentation and tracing
4 of Linux/Android/Chrome platforms and user-space apps.
5 It consists of:
6
7 **A portable, high efficiency, user-space tracing library**
8 designed for tracing of multi-process systems, based on zero-alloc zero-copy
9 zero-syscall (on fast-paths) writing of protobufs over shared memory.
10
11 **OS-wide Linux/Android probes for platform debugging**
12 * Kernel tracing: a daemon that converts Kernel [Ftrace][ftrace] events into
13 API-stable protobufs, on device, with low overhead.
14 * [Heap profiling](heapprofd): low-overhead, out of process unwinding,
15 variable sample rate, attachable to already running processes.
16 * Power rails sampling
17 * System stat counters
18 * Chrome userspace tracing
19 * I/O tracing
20 * Many new probes coming soon: heap profiling, perf sampling, syscall tracing.
21
22 **Processing of traces**
23 [A C++ library for efficient processing and extraction of trace-based
24 metrics.](trace-processor). The library accepts both protobuf and json-based
25 traces as input and exposes an SQL query interface to the data.
26 The library is built to be linked by other programs but can also be used
27 standalone as a command line tool.
28
29
30 **Web-based frontend**
31 An open-source UI for inspection and analysis of traces.
32 Available at [ui.perfetto.dev](https://ui.perfetto.dev).
33 The UI is built on top of C++ trace processor library which is cross-compiled
34 to WASM to run locally in the browser.
35
36
37 ![Perfetto Stack](https://storage.googleapis.com/perfetto/markdown_img/perfetto-stack.png)
38
39 Goals
40 -----
41 Perfetto is building the next-gen unified tracing ecosystem for:
42 - Android platform tracing ([Systrace][systrace])
43 - Chrome platform tracing ([chrome://tracing][chrome-tracing])
44 - App-defined user-space tracing (including support for non-Android apps).
45
46 The goal is to create an open, portable and developer friendly tracing ecosystem
47 for app and platform performance debugging.
48
49 Key features
50 ------------
51 **Designed for production**
52 Perfetto's tracing library and daemons are designed for use in production.
53 Privilege isolation is a key design goal:
54 * The interface for writing trace events are decoupled from the interface for
55 read-back and control and can be subjected to different ACLs.
56 * Despite being based on shared memory, Perfetto is designed to prevent
57 cross-talk between data sources, even in case of arbitrary code execution
58 (memory is shared point-to-point, memory is never shared between processes).
59 * Perfetto daemons are designed following to the principle of least privilege,
60 in order to allow strong sandboxing (via SELinux on Android).
61
62 See [security-model.md](security-model.md) for more details.
63
64 **Long traces**
65 Pefetto aims at supporting hours-long / O(100GB) traces, both in terms of
66 recording backend and UI frontend.
67
68 **Interoperability**
69 Perfetto traces (output) and configuration (input) consists of protobuf
70 messages, in order to allow interoperability with several languages.
71
72 See [trace-format.md](trace-format.md) for more details.
73
74 **Composability**
75 As Perfetto is designed both for OS-level tracing and app-level tracing, its
76 design allows to compose several instances of the Perfetto tracing library,
77 allowing to nest multiple layers of tracing and drive then with the same
78 frontend. This allows powerful blending of app-specific and OS-wide trace
79 events.
80 See [multi-layer-tracing.md](multi-layer-tracing.md) for more details.
81
82 **Portability**
83 The only dependencies of Perfetto's tracing libraries are C++11 and [Protobuf lite][protobuf] (plus google-test, google-benchmark, libprotobuf-full for testing).
84
85 **Extensibility**
86 Perfetto allows third parties to defined their own protobufs for:
87 * [(input) Configuration](/protos/perfetto/config/data_source_config.proto#52)
88 * [(output) Trace packets](/protos/perfetto/trace/trace_packet.proto#36)
89
90 Allowing apps to define their own strongly-typed input and output schema.
91 See [trace-format.md](trace-format.md) for more details.
92
93 Bugs
94 ----
95 * For bugs affecting Android or the tracing internals use the internal
96 bug tracker ([go/perfetto-bugs](http://goto.google.com/perfetto-bugs)).
97 * For bugs affecting Chrome use http://crbug.com, Component:Speed>Tracing
98 label:Perfetto.
99
100
101 [ftrace]: https://www.kernel.org/doc/Documentation/trace/ftrace.txt
102 [systrace]: https://developer.android.com/studio/command-line/systrace.html
103 [chrome-tracing]: https://www.chromium.org/developers/how-tos/trace-event-profiling-tool
104 [protobuf]: https://developers.google.com/protocol-buffers/
105