Async Profiler
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.
Adjust kernel options before you start using the profiler on Linux. On Windows and macOS, the profiler works out of the box.
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:
Profiler configurations
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
Press Ctrl+Alt+S to open the IDE settings and select Build, Execution, Deployment | Java Profiler.
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.