jlfwong / speedscope

🔬 A fast, interactive web-based viewer for performance profiles.
https://www.speedscope.app
MIT License
5.58k stars 247 forks source link

format: Chrome Trace with instant samples #402

Open javierhonduco opened 2 years ago

javierhonduco commented 2 years ago

👋🏻 Hi!

I was trying to visualise the following Chrome Trace in speedscope, but unfortunately, I get an error.

{
  "traceEvents": [
    {"name": "hi", "cat": "none", "ph": "i", "pid": 22630, "tid": 22630, "ts": 829, "stack": ["a", "b", "c"]},
  ],
  "displayTimeUnit": "ns",
  "otherData": {
    "version": "none"
  },
  "samples": []
}

I have it stored under test.json, and either dragging it or selecting it in the file browser results in this alert:

Unrecognized format! See documentation about supported formats.

Perhaps I have misunderstood something about the Chrome Trace format, or I have made some mistake. I have tried on Perfetto and it worked (almost) right. Notice the missing stacks. But perhaps I don't know how to use its UI 😅 .

javierhonduco commented 2 years ago

Just saw this in the docs:

speedscope supports importing a subset of these events. Namely, it supports B, E, and X events, as well as the M events used to specify the names of processes and threads.

Would be amazing if Speedscope could support "instant" events.

I remembered I had tried with "BEGIN" / "END" events, and this failed, too, with the same error message:

{
  "traceEvents": [
    {"name": "hi", "cat": "none", "ph": "B", "pid": 22630, "tid": 22630, "ts": 829, "stack": ["a", "b", "c"]},
    {"name": "hi", "cat": "none", "ph": "E", "pid": 22630, "tid": 22630, "ts": 849, "stack": ["a", "b", "c"]},
  ],
  "displayTimeUnit": "ns",
  "otherData": {
    "version": "none"
  },
  "samples": []
}
zacharyfmarion commented 11 months ago

@javierhonduco I might be missing something but neither of those look like valid formats according to the spec. Trace events do not have a stack property - if you want to specify stackFrames at a timestamp, you can use the json object format - I'm adding support for it here.

Screenshot 2023-12-21 at 11 03 34 PM
javierhonduco commented 9 months ago

@zacharyfmarion this is great news, thanks so much! 🎉