Skip to content

Feature Request: export as callgrind / export dot graph #676

@ducklin5

Description

@ducklin5

Export as callgrind capture

jrfonseca/gprof2dot is a pretty neat tool for visualizing profiling results as a call graph

Unfortunately, it does not support the firefox profiler format.

To get around this, I generated a script for converting samply's json.gz output to a callgrind.capture file: render_profile.py
This script rudimentary and barely tested but it serves as a reference for how it could be implemented within samply.

The only (free) windows profiler that I know that exports to callgrind is verysleepy. But that project is unmaintained and doesn't support rust very well. VerySleepy also lacked a way to export via cmd line which made it very tedious for automated profiling.

Im sure there are way more tools that are built to analyze callgrind files, so having this as an option in samply would make it compatible with many existing workflow. Combine that with the fact that unlike valgrind, samply already works on windows:🥇

Export as dot graph

Using the above script, I was able to convert the profile results of my windows rust app to a callgrind file.
But the callgrind file is not what I actually need, Its only an intermediate file so that I can use jrfonseca/gprof2dot

It would be pretty awesome if samply could just call the gprof2dot (if a flag like --as-dot is passed and gprof2dot executable exists in path)

Example:

Here is an example call graph I generated:
Image

This is what I currently have to do to generate it:

  1. Install the master version of samply (it has the presymbolicate flag)
    cargo install --git https://github.com/mstange/samply.git samply
  2. record my application with the presymbolicate flag, and also specify where my server.pdb will be (target/debug)
    samply.exe record --presymbolicate --symbol-dir=target\debug\ target\debug\server.exe
  3. convert the profile.json.gz to a callgrind file with render_profile.py
    python render_profile.py profile.json.gz
  4. convert the callgrind file to dot file
    gprof2dot --format=callgrind --output=out.dot profile.capture
  5. convert the dot file to an svg
    dot -Tsvg out.dot -o out.svg

It would be awesome if we could just do samply.exe record --as-svg target\debug\server.exe and it does all of that in one command ✨

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions