jlfwong / speedscope

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

[Feature Request] View Multiple Process Flamegraphs at Once #473

Open cawong2 opened 6 months ago

cawong2 commented 6 months ago

Currently the approach to viewing multiple processes/threads is to switch between processes as implemented in #82, but it would be very nice if instead we could compare them all on the same screen, to compare what is happening across threads.

This could look like: mockup and was wondering if there was an easy way to do this. I tried experimenting with the JSON to hack this out with something like:

{
  "exporter": "speedscope@1.20.0",
  "name": "test.txt",
  "activeProfileIndex": 0,
  "$schema": "https://www.speedscope.app/file-format-schema.json",
  "shared": {
    "frames": [
      {
        "name": "event1"
      },
      {
        "name": "event2"
      }
    ]
  },
  "profiles": [
    {
      "type": "evented",
      "name": "perf-vertx-stacks-01-collapsed-all.txt",
      "unit": "none",
      "startValue": 0,
      "endValue": 500,
      "events": [
        {
          "type": "O",
          "frame": 0,
          "at": 0
        },
        {
          "type": "O",
          "frame": 1,
          "at": 6
        },
        {
          "type": "C",
          "frame": 0,
          "at": 9
        },
        {
          "type": "C",
          "frame": 1,
          "at": 12
        }
      ]
    }
  ]
}

but it gave

Failed to load format Error: Tried to leave frame "event1" while frame "event2" was at the top at 9
    at h._leaveFrame (speedscope.80eb88d2.js:165:8075)
    at h.leaveFrame (speedscope.80eb88d2.js:165:8535)
    at speedscope.80eb88d2.js:171:1753
    at a (speedscope.80eb88d2.js:171:1800)
    at speedscope.80eb88d2.js:171:2361
    at Array.map (<anonymous>)
    at s (speedscope.80eb88d2.js:171:2354)
    at import.7f8cb9f9.js:121:2101
    at Generator.next (<anonymous>)
    at s (import.7f8cb9f9.js:121:780)

so I think this might require some code changes that I'm not familiar with.

jlfwong commented 6 months ago

Hi @cawong2! There's no way to do this in speedscope as the moment. I agree it would be useful, though would be a really significant change of speedscope. Transparently, I think I'm unlikely to take this on any time soon.

In general, I think here's a lot that could be done to make analyzing multithreaded profiles much easier