ui: send plugin_loaded for each plugin's part in a trace load (#8768) See RFC 0053 (#8755) --- This PR sends a `plugin_loaded` event for plugins in a trace load, with how long the plugin's `onTraceLoad()` took and whether it registered any tracks. It's sent through `logAdvancedEvent()`, so only for Googlers, and it carries the same `traceLoadId` as that load's `trace_loaded` event. Some notes on the implementation: 1. **Not every plugin gets an event**: only plugins that registered tracks, plus the 10 slowest plugins. There are many plugins, and an event for every one on every load would add a lot of event volume for little value. Plugins with tracks are the ones the user can actually see on the trace. The 10 slowest are included even without tracks, because plugins load one after another, so a slow plugin delays the whole load even if it shows nothing. 2. **Some events are sent late**: some plugins register their first track after loading has finished, e.g. once a query they started returns. When that happens, that plugin's event is sent then, with the same `traceLoadId` and its `onTraceLoad()` time. 3. **At most one event per plugin per trace load**: we keep track of which plugins have been reported in the current trace load, so no plugin ever gets more than one event sent, that way no deduplication needs to happen on query-time. 4. **`PluginLoadReporter`**: a new class that's created once per trace load on `TraceImpl` that picks which plugins to send events for and sends the events. It takes `AnalyticsInternal` as a dependency injection, so that it can call `.logAdvancedEvent()` on it. The unit tests create a mock `AnalyticsInternal`.
Perfetto is an open-source suite of tools for recording, visualizing and analyzing traces: timelines of what software and the system under it were doing. It is the default tracing system for Android and Chromium. System-wide recording works on Android and Linux. The tracing SDK, the UI and Trace Processor also run on macOS and Windows.
perf, Firefox Profiler, macOS Instruments, pprof, systrace, Fuchsia and more.Open an example Android trace without installing anything, or drag your own trace file onto ui.perfetto.dev.
On Android, with a device connected over adb:
curl -O https://raw.githubusercontent.com/google/perfetto/main/tools/record_android_trace python3 record_android_trace -o trace.pftrace -t 10s sched freq gfx view am wm
The trace opens in the Perfetto UI when recording finishes.
On Linux, record scheduling activity with tracebox:
curl -LO https://get.perfetto.dev/tracebox && chmod +x tracebox curl -LO https://raw.githubusercontent.com/google/perfetto/main/test/configs/scheduling.cfg sudo ./tracebox -o trace.pftrace --txt -c scheduling.cfg
For Chrome, use the recording page in the UI. To trace your own app, see in-app tracing.
curl -LO https://get.perfetto.dev/trace_processor && chmod +x trace_processor ./trace_processor query trace.pftrace \ "SELECT name, COUNT(*) AS cnt FROM slice GROUP BY name ORDER BY cnt DESC LIMIT 10"
Or from Python:
pip install perfetto
from perfetto.trace_processor import TraceProcessor tp = TraceProcessor(trace='trace.pftrace') print(tp.query('SELECT ts, dur, name FROM slice LIMIT 10').as_pandas_dataframe())
ftrace. (Linux cookbook)chrome://tracing, for debugging the browser, V8 and Blink. (Chrome tracing)Not sure where to start? How do I start using Perfetto? picks a path based on what you want to do.
Perfetto is a collection of components that work together:
traced, traced_probes) collect data from many processes and the kernel into a single trace file.See the documentation for the full picture.
See Community and getting help for more. We follow Google's Open Source Community Guidelines.
Contributions are welcome. The contributor guide covers building, testing and sending pull requests.
The Debian packaging of Perfetto is maintained in the Debian Perfetto Salsa repository.
Apache 2.0. See LICENSE for details.