cargo flamegraph
spacejam opened this issue · 13 comments
Hey! As a very heavy flamegraph user I've long been thinking about a cargo flamegraph
command, but have been wary of including the bundle of perl scripts in the popular implementation. Is something like cargo flamegraph
a priority of this project? I can imagine that it could support that use case in a more clean way.
Glad to see effort in the rust + flamegraph space :]
Ooooh, that'd be excellent! We're not directly pushing towards cargo flamegraph
, but that's certainly something this library enables. The tricky part will be to also do the profiling. I think what you'd want is some notion of a profiling "driver" (like perf
or bpftrace
), and cargo flamegraph
would be ~ equivalent to cargo run --release
wrapped in that driver. It'd then feed the resulting output file to the appropriate inferno
collapser and then to inferno::flamegraph
to produce the final flamegraph.
I sadly don't have time myself to work on this, but would be happy to help such a project along and review PRs!
Relatedly, profiling will become so nice once we get the ability to do performance profiling like this:
# bpftrace -e 'profile:hz:499 /pid == 1234/ { @[kstack(folded), ustack(folded)]++ } interval:s:30 { exit() }' | flamegraph > out.svg
Stumbled upon this https://github.com/nokia/not-perf that may be of use in this regard? Looks like that already have the perf data collection part under cargo
@sanga ahh! the missing piece :] it doesn't seem to work on osx, but for linux machines may be a nice way to reduce dependencies
I've got something pretty basic going that seems to work on linux but it relies on the new collapse::Folder
that was added since 0.3
was released. @jonhoo would it be possible to do a release to crates.io to get access to that?
whipped up this little cargo subcommand https://crates.io/crates/flamegraph
it's quite brittle as-is but far more maintainable than the junk shellscripts I've been relying on so far :]
feel free to use it as a basis for anything you use in this repo, etc... I'd like to update it when more collapsing options are available in inferno too since I'm also a big dtrace user!
You should post that to /r/rust!
Reusing https://github.com/nokia/not-perf in another project should be relatively simple; I'd just have to massage it a little into a proper library. @spacejam Hit me up if you're interested and I'll be happy to help out.
flamegraph 0.1.4
now uses @Licenser 's dtrace collapser by default on non-linux systems :]