google / perfetto

Performance instrumentation and tracing for Android, Linux and Chrome (read-only mirror of https://android.googlesource.com/platform/external/perfetto/)
https://www.perfetto.dev
Apache License 2.0
2.81k stars 350 forks source link

[ui plugin] How to select specific tracks in plugins #693

Closed rollysys closed 8 months ago

rollysys commented 8 months ago

Hi there, after tried a long time with visulization in streamlit+vega-lite+trace_processor, I found that it's more effiencient to do visulization in perfetto ui plugin... Now I'm trying to add more "ping tracks" functions for my project. I have modified the example plugin "pin ftrace tracks", and it really helpful. But I want to select more specific tracks, and need some help for this(I'm new to ts and still studying the perfetto ui api/class)

stevegolton commented 8 months ago

Hi @rollysys,

pinTracksByPredicate is the right way to do this, as in the "pin ftrace tracks" example you mentioned.

Unfortunately name is currently the only tag that's available. Plugins should populate track tags when they register tracks with Perfetto, but the concept in general is quite new and thus most don't actually fill these in with any useful information. So we just pass the track name to pinTracksByPredicate instead.

We are planning to make more use of the track tags such as adding upid, utid, cpu, etc soon to the relevant tracks. At that point we'll pass this information through to pinTracksByPredicate as well. Track tags are essential to our plan for managing grouping and sorting going forward, so it's in our road map and will hopefully happen some time line the next few months.

Your last point about selecting tracks whose slice name match some pattern is an interesting problem but we don't have any plans to support it yet. You might be able to make some guesses by looking at the track tags (e.g. trackids) and run your own queries, but that might be quite fragile.

Unfortunately I don't have a better suggestion for you for the time being. Keep an eye on the releases page!