PSA: Script for Merging Multiple Traces

6 views
Skip to first unread message

Petr Cermak

unread,
Mar 31, 2016, 7:06:50 AM3/31/16
to tracing, telemetry
Hi all,

TL;DR: I created a command-line tool for merging traces. This allows you to compare multiple traces in a single Trace Viewer instance.

One of the most frequently requested Trace Viewer features is the ability to open multiple traces simultaneously. Implementing this feature would probably require a complete overhaul of the tool and, consequently, take several months to ship.

To address this need, I created a Python script for merging traces. Given an arbitrary number of trace files, it combines all of them into a single trace file. Instead of just concatenating the underlying lists of trace events, the tool:
  • matches processes and threads from different input traces by common process/thread names, ids and labels,
  • shifts the timestamps of events within each input trace so that they don't overlap with the other input traces' events,
  • updates ids so that stack frames and type names from different input traces do not clash and
  • injects thread slices marking the ranges of input traces within the output trace.
Below is a screenshot of a trace generated using the script. It shows how the merged trace can be used to compare the memory usage of two different Chrome runs.



The script can be found in the Catapult repository (tracing/bin/merge_traces.py). Given input traces input1.json, input2.json, ..., inputN.json, the following command merges them into a single trace output.json (gzip compression is supported for both input and output traces files):

tracing/bin/merge_traces.py input1.json input2.json ... inputN.json -o output.json

I hope people will find this useful. Please let me know if you encounter any issues or have any feedback.

Thanks,
Petr

Nat Duca

unread,
Mar 31, 2016, 10:57:13 AM3/31/16
to Petr Cermak, tracing, telemetry
\o/!

--
You received this message because you are subscribed to the Google Groups "tracing" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tracing+unsubscribe@chromium.org.
To post to this group, send email to tra...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/tracing/CA%2BRv-Pi7ewawyy7Rd0hM8MGmigVwpbgoWLC7_P13VSU16cHYtw%40mail.gmail.com.

Sami Kyostila

unread,
Mar 31, 2016, 11:16:01 AM3/31/16
to Nat Duca, Petr Cermak, tracing, telemetry
Cool! Did I understand correctly that this basically concatenates the different traces instead of interleaving based on the timestamps?

- Sami

to 31. maaliskuuta 2016 klo 15.57 Nat Duca <nd...@chromium.org> kirjoitti:
\o/!

On Thu, Mar 31, 2016 at 4:06 AM, Petr Cermak <petrc...@chromium.org> wrote:
Hi all,

TL;DR: I created a command-line tool for merging traces. This allows you to compare multiple traces in a single Trace Viewer instance.

One of the most frequently requested Trace Viewer features is the ability to open multiple traces simultaneously. Implementing this feature would probably require a complete overhaul of the tool and, consequently, take several months to ship.

To address this need, I created a Python script for merging traces. Given an arbitrary number of trace files, it combines all of them into a single trace file. Instead of just concatenating the underlying lists of trace events, the tool:
  • matches processes and threads from different input traces by common process/thread names, ids and labels,
  • shifts the timestamps of events within each input trace so that they don't overlap with the other input traces' events,
  • updates ids so that stack frames and type names from different input traces do not clash and
  • injects thread slices marking the ranges of input traces within the output trace.
Below is a screenshot of a trace generated using the script. It shows how the merged trace can be used to compare the memory usage of two different Chrome runs.



The script can be found in the Catapult repository (tracing/bin/merge_traces.py). Given input traces input1.json, input2.json, ..., inputN.json, the following command merges them into a single trace output.json (gzip compression is supported for both input and output traces files):

tracing/bin/merge_traces.py input1.json input2.json ... inputN.json -o output.json

I hope people will find this useful. Please let me know if you encounter any issues or have any feedback.

Thanks,
Petr

--
You received this message because you are subscribed to the Google Groups "tracing" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tracing+u...@chromium.org.

--
You received this message because you are subscribed to the Google Groups "tracing" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tracing+u...@chromium.org.

To post to this group, send email to tra...@chromium.org.
Reply all
Reply to author
Forward
0 new messages