tp: stdlib: let android.cujs consume CUJs with typed vsync args and no HWUI frames
Generalise the android.cujs stdlib so that a CUJ producer which cannot emit
the Android-framework style dynamic instant markers
(`J<X>#FT#beginVsync#<id>`, `#FT#endVsync#<id>`, `#FT#end#0`, `#FT#cancel#0`)
and which does not render through HWUI (no `Choreographer#doFrame`) can still
be analysed by android_jank_cuj and friends.
The first such producer is Chrome, which emits a `J<WebContentsScroll>`
TrackEvent slice in its GPU process (the process that owns the SurfaceFlinger
layer) with `ChromeTrackEvent.android_cuj_metrics.{begin_vsync_id,
end_vsync_id, canceled}` as typed args. Nothing in the stdlib is
Chrome-specific; any process emitting the same shape of data is handled
identically.
Changes (all additive, existing paths unchanged):
* base.sql
- New `_cuj_typed_args`: reads the three typed args from the CUJ slice.
- `_cuj_instant_events.begin_vsync/end_vsync`: `coalesce(typed arg, FT#
marker)` - typed args win when present, otherwise identical to before.
- New `_android_jank_cuj_state(cuj_id)`: typed `canceled` first, then the
existing FT#cancel / FT#end marker logic; replaces two inline copies.
- `android_jank_cuj_layer_name`: third, same-process fallback for CUJs
that carry explicit vsync bounds but have no HWUI frames: the
`actual_frame_timeline_slice` layer of the CUJ's own process that
presented at both bounds (most frames wins). CUJs resolved by the two
existing rules are never affected.
* boundaries.sql
- `_android_jank_cuj_vsync_boundary`: include CUJs with `Choreographer#
doFrame`s (as before) OR with explicit vsync bounds and a resolved layer.
`upid` and the column set are unchanged.
* frames.sql
- `android_jank_cuj_slice_summary.state` uses `_android_jank_cuj_state`.
* protos/third_party/chromium/chrome_track_event.proto
- Mirror of crrev.com/c/8705993 (`AndroidCujMetrics`, field 1087).
Behavioural impact: CUJs without typed args and with doFrames are
byte-identical (SystemUI and Gmail reference traces, all 50 existing CUJ/Jank
diff tests). A marker-only CUJ with explicit vsync markers and no HWUI frames
can now get a boundary/frames if one of its own layers spans the range.
Tests: new ChromeCujs diff-test suite with a synthetic trace (GPU-process
`J<WebContentsScroll>` slices with typed args, one completed and one
canceled; distractor frames from the browser process and SystemUI).
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.