catapult-project / catapult

Deprecated Catapult GitHub. Please instead use http://crbug.com "Speed>Benchmarks" component for bugs and https://chromium.googlesource.com/catapult for downloading and editing source code..
https://chromium.googlesource.com/catapult
BSD 3-Clause "New" or "Revised" License
1.91k stars 562 forks source link

Systrace parser should support async flow events #4643

Open nslingerland opened 4 years ago

nslingerland commented 4 years ago

Flow events are super-useful for visualizing the connections between asynchronous events.

Catapult is able to show these for JSON Trace Event Format data:

flow.json

{
  "traceEvents": [
    {
      "cat": "",
      "pid": 15903,
      "tid": 15904,
      "ts": 2000.000000,
      "ph": "B",
      "name": "SenderB"
    },
    {
      "cat": "",
      "pid": 15903,
      "tid": 15904,
      "ts": 2000.201000,
      "ph": "s",
      "name": "IPC",
      "id":"8780d403"
    },
    {
      "cat": "",
      "pid": 15903,
      "tid": 15904,
      "ts": 2000.900000,
      "ph": "E"
    },
    {
      "cat": "",
      "pid": 15875,
      "tid": 15895,
      "ts": 2001.400000,
      "ph": "f",
      "name": "IPC",
      "id": "8780d403"
    },
    {
      "cat": "",
      "pid": 15875,
      "tid": 15895,
      "ts": 2001.400000,
      "ph": "B",
      "name": "Blergh"
    },
    {
      "cat": "",
      "pid": 15875,
      "tid": 15895,
      "ts": 2001.800000,
      "ph": "E"
    }
  ]
}
Screen Shot 2019-07-22 at 10 58 28 AM

flow.systrace

Here is an equivalent systrace:

# tracer: nop
      thread1-15904   [000] ...1  2000.000000: tracing_mark_write: B|15903|SenderB
      thread1-15904   [000] ...1  2000.201000: tracing_mark_write: s|15903|IPC|8780d403
      thread1-15904   [000] ...1  2000.900000: tracing_mark_write: E
      thread2-15895   [000] ...1  2001.400000: tracing_mark_write: f|15875|IPC|8780d403
      thread2-15895   [000] ...1  2001.400000: tracing_mark_write: B|15875|Blergh
      thread2-15895   [000] ...1  2001.800000: tracing_mark_write: E
Screen Shot 2019-07-22 at 10 58 00 AM

-> the flow arrows are not shown

Looking at the Catapult source code for parsing the reason for this is clear:

Android systrace

https://github.com/catapult-project/catapult/blob/master/tracing/tracing/extras/importer/linux_perf/android_parser.html#L103

Chrome trace

https://github.com/catapult-project/catapult/blob/master/tracing/tracing/extras/importer/trace_event_importer.html#L1292

Flow events are {s,f,t} Note that the Android systrace importer only handles {B,E,C,S,F} events. It ignores anything else.