gitmyhub

async-profiler

C++ ★ 9.1k updated 12h ago

Sampling CPU and HEAP profiler for Java featuring AsyncGetCallTrace + perf_events

A low-overhead Java profiler that accurately measures CPU usage, memory allocations, and lock contention by sampling at any point in the program rather than only at safe points, and produces interactive flame graphs.

C++JavaJVMsetup: easycomplexity 3/5

Async-profiler is a tool for measuring the performance of Java programs. When a Java application is running slowly or using more memory than expected, a profiler helps you find out where the bottleneck is. Async-profiler attaches to a running Java process and periodically samples what the program is doing, then produces a report showing which parts of the code are taking up the most time or memory.

One of the things that sets this profiler apart from others is how it collects data. Many older Java profilers have a known accuracy problem where they can only take measurements at certain safe points in the program, which means they miss what is happening in between and produce misleading results. Async-profiler avoids this by using lower-level operating system interfaces to take samples at any point, giving a more accurate picture of where time is actually spent.

The tool can measure several different things: how much CPU time the program uses, where memory is being allocated, native memory allocations and leaks, lock contention (when parts of the program are waiting for each other), and hardware-level events like cache misses or page faults.

Using it is straightforward for the common case. You run a single command with the process ID of your Java application, tell it how many seconds to run, and it saves an interactive flame graph as an HTML file you can open in a browser. A flame graph is a visual chart where each bar represents a function call and the width shows how much time was spent there, making it easy to spot slow areas at a glance.

Async-profiler works on Linux and macOS, supporting both x64 and arm64 processors. Pre-built binaries are available for download, so you do not need to compile it yourself unless you want to. It works with OpenJDK and other Java runtimes built on the HotSpot JVM.

Where it fits