extend flamegraph to take an optional pid and timespan
Adding a timeout to flamegraph would be nice for long running commands.
Example of a command printing output once per second forever:
# flamegraph -o example.svg vfsstat 1
In this scenario being able to pass a 30s timeout value that results in tick-30s { exit(0) }' would be great.
# flamegraph -t 30s -o example.svg vfsstat 1
Additionally being able to run flamegraph against an already running process by specifying a pid and timeout would be nice.
flamegraph -p $(pgrep my-server) -t 30s -o server.svg
Another useful argument would be to defer collection until a certain amount of time has passed, to avoid having a big flamegraph of your application starting up followed by a short section you're actually interested in.
I'm quite in-favor of adding this flag. Also, once it is in place, this library can easily allow applications to generate flamegraphs targeting themselves through the library API.
having it as a -p option is a bad idea, since the package selection in the workspace of the original cargo command is done with this flag.
having it available via --pid is fine
FWIW I use the pid argument of py-spy all the time: https://github.com/benfred/py-spy
Massively helpful for profiling long-running service applications
+1 to add --pid please, I would love to be able to profile something that is already running for an interval
The flamegraph binary already exposes --pid. I suppose this issue is only still open because we don't support a time span (or delay) yet.
The
flamegraphbinary already exposes--pid. I suppose this issue is only still open because we don't support a time span (or delay) yet.
I never tried it, but if so, would be nice to add to the documentation as well (https://github.com/flamegraph-rs/flamegraph#usage) . I will test the pid feature tonight
Would be great if you can submit a PR to clarify the existence of this option in the README.
Tested, it works. Will make a PR!
Looks like this was accidentally closed? A way to stop recording before the process ends would be nice to have.
I won't be able to work on that myself, but would be happy to review a PR.