xref: /aosp_15_r20/external/perfetto/docs/quickstart/traceconv.md (revision 6dbdd20afdafa5e3ca9b8809fa73465d530080dc)
1*6dbdd20aSAndroid Build Coastguard Worker# Quickstart: Trace conversion
2*6dbdd20aSAndroid Build Coastguard Worker
3*6dbdd20aSAndroid Build Coastguard Worker_This quickstart demonstrates how Perfetto traces can be converted into other trace formats using the `traceconv` tool._
4*6dbdd20aSAndroid Build Coastguard Worker
5*6dbdd20aSAndroid Build Coastguard Worker![](/docs/images/traceconv-summary.png)
6*6dbdd20aSAndroid Build Coastguard Worker
7*6dbdd20aSAndroid Build Coastguard Worker## Prerequisites
8*6dbdd20aSAndroid Build Coastguard Worker
9*6dbdd20aSAndroid Build Coastguard Worker- A host running Linux or MacOS
10*6dbdd20aSAndroid Build Coastguard Worker- A Perfetto protobuf trace file
11*6dbdd20aSAndroid Build Coastguard Worker
12*6dbdd20aSAndroid Build Coastguard WorkerThe supported output formats are:
13*6dbdd20aSAndroid Build Coastguard Worker
14*6dbdd20aSAndroid Build Coastguard Worker- `text` - protobuf text format: a text based representation of protos
15*6dbdd20aSAndroid Build Coastguard Worker- `json` - Chrome JSON format: the format used by chrome://tracing
16*6dbdd20aSAndroid Build Coastguard Worker- `systrace`: the ftrace text format used by Android systrace
17*6dbdd20aSAndroid Build Coastguard Worker- `profile` : pprof-like format. Either for traces with with
18*6dbdd20aSAndroid Build Coastguard Worker  [native heap profiler](/docs/data-sources/native-heap-profiler.md) dumps or
19*6dbdd20aSAndroid Build Coastguard Worker  [callstack sampling](/docs/quickstart/callstack-sampling.md) (note however
20*6dbdd20aSAndroid Build Coastguard Worker  callstacks requires the `--perf` flag).
21*6dbdd20aSAndroid Build Coastguard Worker
22*6dbdd20aSAndroid Build Coastguard Worker## Setup
23*6dbdd20aSAndroid Build Coastguard Worker
24*6dbdd20aSAndroid Build Coastguard WorkerTo use the latest binaries:
25*6dbdd20aSAndroid Build Coastguard Worker
26*6dbdd20aSAndroid Build Coastguard Worker```bash
27*6dbdd20aSAndroid Build Coastguard Workercurl -LO https://get.perfetto.dev/traceconv
28*6dbdd20aSAndroid Build Coastguard Workerchmod +x traceconv
29*6dbdd20aSAndroid Build Coastguard Worker./traceconv [text|json|systrace|profile] [input proto file] [output file]
30*6dbdd20aSAndroid Build Coastguard Worker```
31*6dbdd20aSAndroid Build Coastguard Worker
32*6dbdd20aSAndroid Build Coastguard WorkerFor versioned downloads, replace `<tag>` with the required git tag:
33*6dbdd20aSAndroid Build Coastguard Worker
34*6dbdd20aSAndroid Build Coastguard Worker```bash
35*6dbdd20aSAndroid Build Coastguard Workercurl -LO https://raw.githubusercontent.com/google/perfetto/<tag>/tools/traceconv
36*6dbdd20aSAndroid Build Coastguard Workerchmod +x traceconv
37*6dbdd20aSAndroid Build Coastguard Worker./traceconv [text|json|systrace|profile] [input proto file] [output file]
38*6dbdd20aSAndroid Build Coastguard Worker```
39*6dbdd20aSAndroid Build Coastguard Worker
40*6dbdd20aSAndroid Build Coastguard Worker## Converting to systrace text format
41*6dbdd20aSAndroid Build Coastguard Worker
42*6dbdd20aSAndroid Build Coastguard Worker`./traceconv systrace [input proto file] [output systrace file]`
43*6dbdd20aSAndroid Build Coastguard Worker
44*6dbdd20aSAndroid Build Coastguard Worker## Converting to Chrome Tracing JSON format
45*6dbdd20aSAndroid Build Coastguard Worker
46*6dbdd20aSAndroid Build Coastguard Worker`./traceconv json [input proto file] [output json file]`
47*6dbdd20aSAndroid Build Coastguard Worker
48*6dbdd20aSAndroid Build Coastguard Worker## Converting to pprof profile.
49*6dbdd20aSAndroid Build Coastguard Worker
50*6dbdd20aSAndroid Build Coastguard WorkerThis extract all samples from the trace, and outputs a proto that is compatible
51*6dbdd20aSAndroid Build Coastguard Workerwith pprof.
52*6dbdd20aSAndroid Build Coastguard Worker
53*6dbdd20aSAndroid Build Coastguard WorkerIf you are extracting heaps profiles like heapprofd you can use the following:
54*6dbdd20aSAndroid Build Coastguard Worker
55*6dbdd20aSAndroid Build Coastguard Worker`~/traceconv profile [input proto file] [output file]`
56*6dbdd20aSAndroid Build Coastguard Worker
57*6dbdd20aSAndroid Build Coastguard WorkerHowever if you are using callstack sampling like traced_perf then use the
58*6dbdd20aSAndroid Build Coastguard Workerfollowing instead:
59*6dbdd20aSAndroid Build Coastguard Worker
60*6dbdd20aSAndroid Build Coastguard Worker`~/traceconv profile [input proto file] [output file] --perf`
61*6dbdd20aSAndroid Build Coastguard Worker
62*6dbdd20aSAndroid Build Coastguard WorkerNote for `--perf` the output is one pprof file per process sampled in the trace.
63*6dbdd20aSAndroid Build Coastguard WorkerYou can use pprof to merge them together if desired.
64*6dbdd20aSAndroid Build Coastguard Worker
65*6dbdd20aSAndroid Build Coastguard Worker## Opening in the legacy systrace UI
66*6dbdd20aSAndroid Build Coastguard Worker
67*6dbdd20aSAndroid Build Coastguard WorkerIf you just want to open a Perfetto trace with the legacy (Catapult) trace
68*6dbdd20aSAndroid Build Coastguard Workerviewer, you can just navigate to [ui.perfetto.dev](https://ui.perfetto.dev),
69*6dbdd20aSAndroid Build Coastguard Workerand use the _"Open with legacy UI"_ link. This runs `traceconv` within
70*6dbdd20aSAndroid Build Coastguard Workerthe browser using WebAssembly and passes the converted trace seamlessly to
71*6dbdd20aSAndroid Build Coastguard Workerchrome://tracing.
72