Closed rrva closed 7 years ago
+1 - sounds like a nice feature to add.
@rrva You may be interested in https://github.com/cykl/hprof2flamegraph. I just added a stackcollapse-hpl script to convert an hpl file into folded stacks. Feedback is welcome.
@RichardWarburton I don't really mind were this script is hosted. I plan to add support of a few more profilers, so it makes sense to me to store all the scripts in a dedicated project. But if users find it more convenient to have the script in the honest-profiler source tree, I'm fine with that too.
@RichardWarburton if you are interested, I have a trivial class that takes an hpl file and converts it into folded stacks; the only advantage over the script in https://github.com/cykl/hprof2flamegraph is that it uses honest-profiler's reader, so it won't break if the format is changed. I can clean it up and send a pull request if you want (just tell me which package/class name would you like for it).
@mbarbon I decided to not use the Java API because I find it easier to package / deploy / use a python script than a JAR but understand that someone could prefer to use the official API. (btw. I have not used honest-profiler lately. If you use my script feel free to report any issue & I will fix them.)
@mbarbon a pull request would be fantastic! With respect to package I suspect that core.collector
would be a good place. I'll let you pick a name and reserve the right to suggest an alternative in the pull request comments if I can think of anything better ;)
I'm not in a java project at the moment, so no current need, but my usage scenario was:
Get a flame graph from a live production system in order to troubleshoot. This also includes the possibility to inject the profiler agent into an already running process, which was not started with the agent.
I experimented with this, and it is actually possible:
[VirtualMachine.loadAgentPath](http://docs.oracle.com/javase/6/docs/jdk/api/attach/spec/com/sun/tools/attach/VirtualMachine.html#loadAgentPath%28java.lang.String, java.lang.String%29)
A bit off-topic, but if there is interest I might do a PR for injection.
I would happily accept a PR for injection.
I've pushed an experiment for rendering the flame graphs from @mbarbon in Javafx. Its currently ugly both in terms of the UI and the code. But this can be integrated and tidied up in due course.
@mbarbon Can you post that script? The https://github.com/cykl/hprof2flamegraph is bombing out...
It has already been merged in honest-profiler: https://github.com/RichardWarburton/honest-profiler/blob/master/src/main/java/com/insightfullogic/honest_profiler/ports/console/FlameGraphDumperApplication.java
@mbarbon Well ok then ;)
@mbarbon Hope you are happy with the Java dumper. If not, I just fixed stackcollapse-hpl to support the new, cough almost one year old, full frame events. Should work fine now.
given current state of play I believe we can close this issue. There's a collapsed stack convertor and a ui view to support flamegraphs. Further issues/enhancements can be filed separately.
CPU flame graphs are a useful way of visualizing a lot of stacktraces. It would be nice to have an output mode which is compatible with the input of the flame graph tools at https://github.com/brendangregg/FlameGraph or alternatively a renderer output in the UI which draws flame graphs. If it is implemented in the UI, it would be important to be able to generate a flame graph from a previously recorded log file as well as some live snapshot mode.