Fully featured low overhead profiler for Java EE and Java SE platforms.
Easy-to-use performance and memory .NET profiler for Windows, Linux and macOS.
Secure and easy profiling in cloud, containers and clustered environments.
Performance monitoring and profiling of Jenkins, Bamboo, TeamCity, Gradle, Maven, Ant and JUnit.

Asynchronous CPU sampling

Asynchronous sampling is a CPU profiling mode which provides much better accuracy of collected stack traces and lower overhead than the classic synchronous CPU sampling.

Asynchronous CPU sampling is a low overhead profiling mode that does not suffer from a Safepoint bias problem. It features HotSpot-specific APIs to collect stack traces. It works with OpenJDK, Oracle JDK and other Java runtimes based on the HotSpot JVM. This mode is available only on a limited number of platforms.

Asynchronous sampling is available in two modes: asynchronous CPU sampling and asynchronous periodic CPU sampling.

Asynchronous CPU sampling

Unlike classic synchronous sampling which periodically queries stacks of all application threads, asynchronous CPU sampling works differently. The profiler sets a timer which counts down against both user and system CPU time consumed by all threads in the process. As soon as the counter exceeds the pre-defined CPU time threshold, the profiler collects the call stack in the thread which caused the timer expiration.

Asynchronous CPU sampling always measures CPU time. Due to the nature of system CPU timers wall time cannot be measured.

Time measurement accuracy is high for methods consuming CPU cycles. Methods like sleep() and wait() which don't consume CPU time will not be shown in the results.

Asynchronous periodic CPU sampling

Like classic synchronous sampling, the asynchronous periodic sampling also periodically queries stacks of all application threads.

Unlike classic synchronous sampling, the asynchronous periodic sampling does not do it by obtaining all thread stacks at a time, but instead periodically sends a signal to each live thread to accurately sample its own stack.

Like classic synchronous sampling and unlike asynchronous CPU sampling, asynchronous periodic sampling measures CPU or wall time depending on the sampling settings.

Starting asynchronous CPU sampling

Use profiler toolbar to start asynchronous sampling as shown on the picture below. There are also alternate methods to start CPU profiling.

CPU asynchronous sampling

System requirements

  • HotSpot JVM.
  • Operating systems:
    • Linux: x64, x86, ARM 32-bit (ARMv7 and higher, hard-float), ARM 64-bit (AArch64), ppc64le
    • macOS: x64, arm64

Overhead

Asynchronous sampling overhead is lower than in other sampling modes and lower than overhead of tracing. However, the probes for the high-level statistics, if enabled, may impose additional overhead.

See also: Profiling overhead: how to reduce or avoid.

Sampling settings

Asynchronous profiling can be configured with the sampling settings.

  • Asynchronous CPU sampling:

  • Asynchronous periodic sampling:

    • Configure the sampling period by using the property sampling_period_ms.
    • Choose between measuring CPU time (default) or wall time by using the property time.

Disabling asynchronous sampling

Asynchronous sampling will be disabled if the startup option disable_async_sampling or disable_all is specified.

YourKit uses cookies and other tracking technologies to improve your browsing experience on our website, to show you personalized content, to analyze our website traffic, and to understand where our visitors are coming from.

By browsing our website, you consent to our use of cookies and other tracking technologies in accordance with the Privacy Policy.