Oct 17, 2023

clj-async-profiler 1.1.0: right-click menu and startup profiling

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:

New right-click menu.

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.

Example 1.1.0 flamegraph. Click to open.

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 print-jvm-opt-for-startup-profiling that simplifies enabling the profiler from the very launch of the JVM. I've described this new functionality in the KB article.

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!