tree: 8c621b1ca7829c51b4e141956f89e9fcb0cb712e [search]
  1. src/
  2. BUILD.bazel
  3. BUILD.gn
  4. README.md
src/performance/fxtdump/README.md

A cli tool to inspect .fxt files

Usage:

Locating invalid records

# e.g. to locate invalid records in a trace
fx fxtdump dump trace.fxt --strict
...
...
0x0d9ffb40: Event(EventRecord { provider: Some(Provider { id: 61, name: "starnix_kernel.cm" }), timestamp: 935523250156, process: ProcessKoid(46458), thread: ThreadKoid(46460), category: "kmem_stats_a", name: "starnix:pager", args: [Arg { name: "name", value: String("write") }], payload: DurationEnd })
ERROR couldn't parse string as utf-8

Will get you the offset into the trace directly before where which we encountered a corrupted record.

Checking a trace for lost data

fxtdump check walks the raw FXT records and reports data that was lost, including losses that trace_processor drops without recording: provider buffer-full events, malformed or dropped Perfetto blobs, a corrupt or cut-off joined Perfetto stream, record size errors and large records that trace_processor misreads.

fx fxtdump check <trace.fxt | -> [--format text|json] [--expect-providers a,b]
  • The trace may be raw, zstd- or gzip-compressed. A path whose suffix (as in Python's pathlib, so not a file named just .gz) is .zst or .gz is always decoded as such; other paths and - (stdin) are sniffed by their magic bytes. A zstd stream may start with a skippable frame.
  • --expect-providers lists provider names that must appear in the trace.
  • The exit status is 0 for CLEAN, 1 for TRUNCATED or UNUSABLE (also when the trace can't be read), and 2 for usage errors.
$ fx fxtdump check empty_activity_trace.fxt
### FXT Check: TRUNCATED

- File: `empty_activity_trace.fxt` (109546048 bytes, 2147374 records)
- last Perfetto packet cut off (9045 bytes missing)

| perfetto status | blobs | malformed | payload bytes | packets |
| --- | --- | --- | --- | --- |
| TRAILING | 4027 | 0 | 15666680 | 380 |

| provider | id | records | bytes | buffer full events |
| --- | --- | --- | --- | --- |
| ktrace_provider | 52 | 1416280 | 69023840 | 0 |
| starnix_kernel.cm | 60 | 498627 | 33060888 | 0 |
...

| detail | value |
| --- | --- |
| parsed bytes | 109546048 |
...
| perfetto trailing missing bytes | 9045 |

--format json prints the same report for tools:

$ fx fxtdump check --format json calendar_cold.traced_trace.fxt.zst
{
  "path": "calendar_cold.traced_trace.fxt.zst",
  "schema_version": 1,
  "verdict": "CLEAN",
  "reasons": [],
  "file_bytes": 341552800,
  "parsed_bytes": 341552800,
  "records": 5985003,
  ...
  "providers": [
    {
      "provider_id": 36,
      "name": "ktrace_provider",
      "records": 4047715,
      "bytes": 197298736,
      "buffer_full_events": 0
    },
    ...
  ],
  "perfetto": {
    "blobs": 48843,
    ...
    "packets": 33050,
    ...
    "status": "OK"
  }
}

Checker behavior:

  • stops at the first record whose size is zero or runs past the end of the trace (including 1 to 7 trailing bytes), since nothing reliable is left to skip by;
  • still counts a provider info record whose name overruns it, and stops at its offset;
  • joins Perfetto blobs that come before any provider section;
  • after a corrupt Perfetto frame, resyncs at the next blob that starts a packet, only to count further damage, so a cut-off last packet can be reported along with corruption;
  • rejects gzip headers with reserved flag bits, bad header CRCs (FHCRC), or file names/comments longer than 65535 bytes as UNUSABLE;
  • options must be written --format json (not --format=json) and may be given only once; either mistake is a usage error (exit 2).

Inspecting Trace Size

$ fx fxtdump category_stats trace.fxt
+-------------------+------------+---------+
| Category          | Size       | Count   |
+-------------------+------------+---------+
| kernel:vm         | 127451 KiB | 1812649 |
+-------------------+------------+---------+
| kernel_sched      | 49889 KiB  | 1069634 |
+-------------------+------------+---------+
| kernel:contention | 33571 KiB  | 715898  |
+-------------------+------------+---------+
| kernel:power      | 28322 KiB  | 517899  |
+-------------------+------------+---------+
| gfx               | 7009 KiB   | 241187  |
+-------------------+------------+---------+
| magma             | 2089 KiB   | 74046   |
+-------------------+------------+---------+
| input             | 948 KiB    | 38862   |
+-------------------+------------+---------+
| kernel:meta       | 188 KiB    | 3441    |
+-------------------+------------+---------+
| memory:kernel     | 49 KiB     | 307     |
+-------------------+------------+---------+
| system_metrics    | 14 KiB     | 420     |
+-------------------+------------+---------+