Last year, I made a major release of clj-async-profiler, introducing dynamic transforms within the flamegraphs. This granted users the ability to arbitrarily modify the profiling data on the fly without regenerating a flamegraph. Such an instrument lets you get a better picture and uncover hidden performance gotchas. For example, a solid usecase for this feature would be exploring the flamegraph of a recursive function, which becomes much more palatable when folded. I personally use dynamic transforms all the time, and they aid me tremendously in deciphering the profiling results. However, I acknowledge that writing regular expressions manually may be intimidating if you are not very familiar with them, and plain tedious if you are.
The release 1.1.0 makes a step towards more user-friendly transforms by adding a custom context menu to flamegraphs. You can now right-click any frame in the flamegraph to open a dedicated menu. Here's what it looks like:
The transforms accessible through the menu are nothing different from what you can write manually. In fact, clicking any of these transforms simply adds a prepared transform to the sidebar on the right. From there, you are free to edit it like any regular transform: disable via a checkbox, modify the expressions, reorder, etc. The main benefit is that the quick actions in the context menu cover many of the cases where you want to alter a flamegraph and are much faster to use than writing a transform by hand.
Let's go over each item in detail. I'll use a sample flamegraph below to demonstrate the new features so you can follow along.
bottom-up-treeframes and choose "Highlight". This will highlight frames with this name everywhere on the flamegraph and show the total matched percentage in the lower right corner. This is the same as writing a Highlight query manually in the sidebar, but quicker. As always, you can click Clear button to clear the highlight.
bottom-up-treeframe again and select this menu item. See that only the stacks containing this frame are now displayed on the flamegraph. You can then uncheck the checkbox next to the added transform and press "Apply"; the flamegraph will revert to the previous state.
thread_startframe, which is the entrypoint to some GC work, and select this menu item. Observe how this part of the flamegraph disappeared.
thread_startframe and select "Hide frames above". All the "noise" above that frame will disappear.
bottom-up-treeconsists of recursive calling of itself and some actual work, but it's hard to tell how parts of that work relate to each other. Let's click any of the
bottom-up-treeframes and select "Collapse recursive". The whole recursive stack will be reduced to a single frame, and the other functions called by the recursive frames will be merged together to paint a much clearer picture.
bottom-up-tree, try highlighting it through the menu. You will see that it is still split into two parts on the graph. That's because the lazy sequence processing machinery calls this function through two disparate code paths. But we can bring those separated samples back together by right-clicking any of the two
bottom-up-treeframes and selecting "Hide frames below". Observe how this frame "dropped" to the bottom of the flamegraph, and the two subgraphs merged into a single one. If you then "Filter" the
bottom-up-tree, you will ultimately get a flamegraph dedicated to just that one function.
That's all the quick transforms available for now. Some more may be added in the future, but these should cover a lot of usecases already. Quick transforms can also be a stepping stone to more complex behavior Start by adding one from the menu and then experiment with expression in the sidebar to reach the most informative view.
This release also adds a function
simplifies enabling the profiler from the very launch of the JVM. I've described
this new functionality in the KB
I hope this new version of clj-async-profiler sparks joy and helps you understand your flamegraphs better. I'll be delighted to hear your suggestions about which other quick transforms are worth adding. Now go ignite some flames!