IntelliJ IDEA 2021.3 Help

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.

Block details shown in the flame graph

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

  1. 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'
  2. 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:

sudo sh -c 'echo kernel.perf_event_paranoid=1 >> /etc/sysctl.d/99-perf.conf' sudo sh -c 'echo kernel.kptr_restrict=0 >> /etc/sysctl.d/99-perf.conf' sudo sh -c 'sysctl --system'

Profiler configurations

IntelliJ IDEA features two pre-defined Async Profiler configurations: the CPU profiler and the memory allocation profiler that you can find in Settings/Preferences | Build, Execution, Deployment | Java Profiler.

Configuring CPU profiler configuration

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

  1. Press Ctrl+Alt+S to open the IDE settings and select Build, Execution, Deployment | Java Profiler.

  2. Select one of the pre-defined CPU or memory profiling configuration or copy the template configuration by clicking the Add button.

  3. Change the values in the Agent options field and apply the changes. For more information, refer to Async Profiler on GitHub.

Last modified: 12 November 2021