1# Visualising large traces 2 3Browsers often limit the amount of memory a site can use. 4This can cause problems when visualising large traces. 5 6## Using TraceProcessor as a native accelerator 7 8Perfetto UI supports offloading the parsing and processing of the trace to a 9'server' instance of TraceProcessor running natively on your local machine. 10This server process can take full advantage of the RAM of your machine as well 11as running at full native (rather than WebAssembly) performance, leveraging 12SSE on modern x86_64 machines. 13 14```bash 15curl -LO https://get.perfetto.dev/trace_processor 16chmod +x ./trace_processor 17./trace_processor --httpd /path/to/trace.pftrace 18``` 19 20Then open https://ui.perfetto.dev as usual. 21 22The Perfetto UI will automatically detect the presence of 23`trace_processor --httpd` by probing http://127.0.0.1:9001 . When detected it 24will prompt a dialog that asks if you want to use the external accelerator via 25a WebSocket or the built-in WebAssembly runtime that runs in the browser. 26 27## Using more than one instance in parallel 28 29NOTE: this is a temporary workaround until getting to a better solution as 30described in [b/317076350](http://b/317076350) (Googlers only). 31 32As per [r.android.com/2940133](https://r.android.com/2940133) (Feb 2024) it is 33possible to run different instances of trace_processor on different ports, and 34point the UI to them. 35 36**Pre-requisite:** Enable the 37[Relax CSP flag](https://ui.perfetto.dev/#!/flags/cspAllowAnyWebsocketPort). You 38need to do this only once. If the flag is not displayed, the CL above has not 39made it into the release channel you are using (try Canary or Autopush) 40 41```bash 42./trace_processor --httpd --http-port 9001 trace1.pftrace 43./trace_processor --httpd --http-port 9002 trace2.pftrace 44./trace_processor --httpd --http-port 9003 trace3.pftrace 45``` 46 47Then open the UI in three tabs as follows: 48* https://ui.perfetto.dev/#!/?rpc_port=9001 49* https://ui.perfetto.dev/#!/?rpc_port=9002 50* https://ui.perfetto.dev/#!/?rpc_port=9003 51 52## How big is too big? 53 54The exact memory limit can vary by browser, architecture, and OS however 2GB is 55typical. This limit is a limit on the total memory used at runtime, not on the 56binary size of the trace. 57The `trace_processor` (and hence the UI) representation of a trace at runtime is 58normally larger than the binary size of that trace. 59This is because the representation is optimized for query performance rather 60than size. The exact inflation factor varies depending on the trace format but 61can be 2-4x for uncompressed proto traces. 62