explaingit

async-profiler/async-profiler

9,026C++Audience · developerComplexity · 3/5Setup · easy

TLDR

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.

Mindmap

mindmap
  root((async-profiler))
    Measurements
      CPU time
      Memory allocation
      Lock contention
      Hardware events
    Output
      Flame graphs
      Text reports
    Platforms
      Linux
      macOS
    Runtimes
      OpenJDK
      HotSpot JVM
    Use Cases
      Performance tuning
      Memory leak detection
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Generate a flame graph to find which part of your Java app is consuming the most CPU time.

USE CASE 2

Detect memory allocation hotspots in a running Java service without restarting the process.

USE CASE 3

Measure lock contention to find where threads are blocking each other in a multithreaded app.

USE CASE 4

Profile native code paths alongside JVM bytecode to get a complete picture of performance.

Tech stack

C++JavaJVM

Getting it running

Difficulty · easy Time to first run · 30min

Requires a running JVM process to attach to, pre-built binaries available for Linux and macOS on x64 and arm64.

In plain English

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.

Copy-paste prompts

Prompt 1
I have a slow Java microservice running in production. Walk me through attaching async-profiler to the running process and generating a CPU flame graph to find the bottleneck.
Prompt 2
My Java app is allocating too much memory and triggering frequent garbage collection. How do I use async-profiler to find which code paths are allocating the most objects?
Prompt 3
Help me use async-profiler to detect lock contention in my multithreaded Java application. What command do I run and how do I interpret the results?
Prompt 4
I want to run async-profiler inside a Docker container against a JVM-based app. What steps do I follow and what Linux kernel permissions or flags do I need?
Open on GitHub → Explain another repo

← async-profiler on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.