Perfetto UI

This section describes how to use Perfetto UI to visualize dftracer traces.

Loading traces

There are two ways to load traces into Perfetto UI:

  1. Directly in the website

    Warning

    Use this if your traces are small

    • Go to Perfetto UI

      Perfetto UI Interface
    • On the top left corner, click Open trace file button and it will ask you to specify the location of the trace file

    • After loading, you can see your trace file now is visualized in Perfetto UI

      Perfetto Visualization
  2. Using trace_processor

    Note

    This is a recommeded way to load BIG traces into Perfetto UI. Using this your trace file will be loaded natively rather than in your browser.

    • Go to Perfetto UI Trace Processor and download the trace_processor

    • After downloading, assuming that it is in the current directory, now you can bridge Perfetto UI with trace_processor by running the following command:

      ./trace_processor --httpd --http-port <PORT> <trace file>
      
    • Then, in your browser, go to https://ui.perfetto.dev/?rpc_port=<PORT>

      • If the Perfetto UI ask for confirmation below, then click the button Take me to the flags page

        Perfetto Flags Confirmation
      • Now, changed this line from disabled to enabled** and reopen https://ui.perfetto.dev/?rpc_port=<PORT>

        Perfetto Confirm CSP
    • Perfetto UI will ask for confirmation to choose the UI. For this use case, we just need to choose Use mismatched version regardless (might crash)

      Perfetto UI Confirmation
    • Now, after done, you can see the same visualization as shown above in the first step

Using SQL Query

If you want to do simple trace analysis, fortunately, Perfetto UI provides a SQL query interface.

To do this, click the textbox at the top as shown below

Perfetto SQL Text Box Navigation

To start typing SQL query, you should type : and then the text box will change into darker color as shown below

Perfetto SQL Text Box

Now, we can start typing SQL Query! For the list of tables that can be queried inside Perfetto UI, you can see it in Perfetto Trace Processor Documentation.

Here are some examples that can help you to get started:

Query pread ordered by duration

select * FROM slice WHERE name="pread" ORDER BY dur DESC LIMIT 100
Query pread ordered by duration using Perfetto UI with SQL Query

Query number of __getitem__

select count(*) FROM slice WHERE name LIKE "%__getitem__%"

Find Thread ID of __getitem__

SELECT DISTINCT thread.name as thread_name FROM slice JOIN thread_track ON thread_track.id = slice.track_id JOIN thread using (utid) WHERE slice.name LIKE "%__getitem__%"