John Gallagher

Viewing Flamegraphs Generated on a Remote Machine

September 2021

Sometimes I debug performance issues, and when I do, I often use flamegraphs. My typical workflow used to consist of me doing the following in a loop:

  1. Tweak the system being investigated, usually some remote VM
  2. On the remote VM, start the workload and run some monitoring tool that produces a flamegraph in HTML or SVG format
  3. scp the flamegraph from the remote VM back to my local machine
  4. Open the flamegraph in my browser and analyze it
I recently realized that I could improve this process by just starting a temporary HTTP server on the remote system, rather than manually scp-ing the flamegraph back to my local machine again and again. There are many HTTP server one-liners out there, the one I use is
$ python -m http.server 8080
I start it in the directory where I put the output of the flamegraph tool, and usually inside a tmux session to prevent it from dying when I log out for the day. Then I can point my browser at the HTTP server and open the HTML or SVG file directly, eliminating step 3 from my debugging process.

It's such a simple, and in retrospect obvious, change to my workflow, but it makes the iterative debugging process much more seamless. An additional benefit is that you can share interesting findings with any colleagues who have access to the network where the VM is located just by sending them a URL to a flamegraph.