Add support for merging traces
It's become clear that we need some way to have multiple independent traces (collected on either the same device or different devices) visualized and analyzable on a single timeline.
Most of the work for this already exists in the trace processor but it is very hard for anyone who does not understand a lot of the internals of TP to make use of it.
This bug tracks the remaining implementation which involves some small work in TP and then some non-trivial work in the UI to expose this functionality.
Will be looking to this actively in the coming month.
Current state:
- I'm now pretty happy with the UI part of things, we have a pretty initial draft for "clock synchronisation" between traces.
- There is some work to be done in trace processor to take the result of what the UI builds for clock sync and actually make use of this while parsing. This will require defining the JSON schema we expect folks to use and making the UI write it as well
- Work on multiple machines has not started yet but I remain convinced it's not too much work on top of what we already are doing for single machine merging.
@LalitMaganti Thanks for woring on this impritant feature! If the user does not care about multiple machines and the UI function, is there a cmdline util that works to merge two pftraces from the same machine (captured around the same period) into a single pftrace file? If so any instructions? Thanks!
No sorry you will have to wait until this is done. I'm not giving preview instructions, this is not yet complete.
From my previous comment
There is some work to be done in trace processor to take the result of what the UI builds for clock sync and actually make use of this while parsing. This will require defining the JSON schema we expect folks to use and making the UI write it as well
For anyone reading this bug: I now feel comfortable enough for people to start using this and reporting bugs. Note that it's still very experimental.
Here's how you do it:
- Switch to the "autopush" channel of the UI: Click "Flags" on the sidebar, then "Release Channel" and switch to "Autopush"
- Refresh the page
- Click "Plugins" on the sidebar and enable "dev.perfetto.MultiTraceOpen"
- Refresh the page
- You should then get a new sidebar option called "Open Multiple Trace Files" -> this will allow you to popup a dialog which let's you choose multiple traces and then merge them together on the timeline
There are some limitations on this:
- The data should be collected on the same machine at the same time. Multiple-machines/same time and comparing different traces collected at different types on same/different machines is not supported, They are tracked by child bugs
- There is an assumption that all the traces are talking about the same "shared" set of clocks. One of the things I want to solve is to allow overriding which clock is used in each trace but for now, everything needs to use consistent clocks
Give it a try and please give all feedback on this bug!
Thanks, is there a cmdline tool that can merge multiple traces into one?
At the moment I do not want to commit to stabilizing that. The hidden method is to tar/zip files together (that's what the UI is doing behind the scenes). But there are known cases where doing this is not sufficient which is why I don't want to stabilise this.
Update on this issue: I'm continuing to slowly chip away at all the small behind the scenes issues which I was aware of but was making me uncomfortable stabilizing this feature: https://github.com/google/perfetto/pull/4805, https://github.com/google/perfetto/pull/4804, https://github.com/google/perfetto/pull/4791, https://github.com/google/perfetto/pull/4708, https://github.com/google/perfetto/pull/4661, https://github.com/google/perfetto/pull/4570, https://github.com/google/perfetto/pull/4571, https://github.com/google/perfetto/pull/4625, https://github.com/google/perfetto/pull/4604
With all of these changes (and several others), I'm feeling a lot more comfortable about the robustness of this feature and our ability to support it. So in the nearish feature I think I will make this official.
The final pieces are now landing starting with https://github.com/google/perfetto/pull/6202 which adds the JSON file I've talked about for a long time but finally got round to committing to. I need to add clock and machine parts to it but once that's done, it's just a matter of documentation, the last bit of UI polish and turning it on by default.
https://github.com/google/perfetto/pull/6473 now enables thie feature by default in the autopush UI.
The big missing piece is documentation which I will add shortly.
https://github.com/google/perfetto/pull/6493 is the final piece, comprehensively documenting this feature. It'll be available in v58, launching in ~1 month.
Thanks, is there a cmdline tool that can merge multiple traces into one?
FWIW, https://github.com/google/perfetto/pull/6495 adds this as a first class tool, though, as specified in the docs, it's basically the same as tarring/zipping the files together: the only bonus is that we do some extra checks of whether the clocks line up and tell you and we allow you to pass the manifest file and pre-validate it for you.