Async Profiler monitors JVM-level parameters of your application to provide a better understanding of how your application is executed and how exactly memory and CPU resources are allocated. This data can help you find and resolve performance problems and bottlenecks.
Async Profiler does not require threads to be at safe points to be able to sample stacks, which means that it avoids the safepoint bias problem. On top of that, the profiler features Flame Graph support that allows it to visualize stack traces.
Before you start using the profiler on Linux, install the Perf tool and adjust kernel options. On macOS, the profiler works out of the box.
Install Perf on Linux
Install the Perf tool for your particular kernel release.
uname -rto find out the exact version, and then install the corresponding linux-tools package. For example:$ uname -r 4.15.0-36-generic $ sudo apt-get install linux-tools-4.15.0-36-generic
Adjust kernel options on Linux
Adjust perf_event_paranoid. This option controls the use of the performance events data by non-root users.
Set the value to be less than 2 to let the profiler collect performance information without root privileges:sudo sh -c 'echo 1 >/proc/sys/kernel/perf_event_paranoid'
Adjust kptr_restrict. This option sets restrictions on exposing kernel addresses.
To have kernel symbols properly resolved, disable the protection offered by kptr_restrict by setting its value to 0:sudo sh -c 'echo 0 >/proc/sys/kernel/kptr_restrict'
By default, these changes affect your current OS session only. To keep the settings across system reboots, run:
IntelliJ IDEA features two pre-defined Async Profiler configurations: the CPU profiler and the memory allocation profiler that you can find in.
These configurations are adjusted to provide the most accurate results, that is why they don't require any modifications. However, you can still change the values in the settings.
Modify a profiling configuration
Select one of the pre-defined CPU or memory profiling configuration or copy the template configuration by clicking .
Change the values in the Agent options field and apply the changes. For more information, refer to Async Profiler on GitHub.
Profile your application with Async Profiler
You can run the profiler for projects built with Gradle and with the native IntelliJ IDEA build tool. If you use Maven, you can run the application with the native IntelliJ IDEA runner to get the profiling data.
Use any of the following options to analyze your application:
Click on the toolbar (or click the icon in the gutter) and select Run 'run configuration name' with 'profiler configuration name':
From the main menu, select Run 'run configuration name' with 'configuration name').and then select the necessary configuration (
(Only for Linux) Upon the first launch of the profiler, IntelliJ IDEA checks whether kernel variables are already set up and suggests the necessary changes:
When the profiling data is ready, you will see a confirmation popup together with the Profiler tool window bar. Click this bar to open the Profiler tool window or go to if you don't use tool window bars.
When the analysis is finished, you can review the reports.