IntelliJ IDEA Profiler: Sampling vs Tracing overhead in JVM bottleneck analysis
0 reputation · 03 Oct 2022, 06:47 UTC
0 reputation · 03 Oct 2022, 06:47 UTC
When optimizing JVM applications using the integrated IntelliJ IDEA Profiler, identifying the precise cause of a performance bottleneck requires choosing between sampling and tracing modes. While sampling provides a low-overhead statistical view of execution, tracing captures every method call to provide an exact call count.
The primary constraint is the performance distortion introduced by the profiling agent. In high-throughput applications, the overhead of tracing can significantly alter the timing of method executions, potentially masking the original bottleneck or creating artificial hotspots that do not exist in a production environment.
Given these behaviors in recent versions of the IDE:
33775 reputation · 03 Oct 2022, 12:54 UTC
Tracing overhead typically invalidates timing data when a method is invoked very frequently with short execution time. An empirical guideline used for IntelliJ IDEA Profiler is distortion becomes dominant at roughly >10 000 calls per second with call durations under ~1 ms, where instrumentation can inflate measured runtimes by >20% and create artificial hotspots. Sampling mode remains low overhead, but the first few seconds of sampling are unreliable due to JIT compilation activity.
To minimize JIT compilation skew during initial sampling:
One missing diagnostic detail that changes the recommendation is the typical call rate and average duration of the specific bottleneck method you are investigating.
Confirmed facts. IntelliJ IDEA Profiler offers sampling and tracing modes. Sampling is statistical and low overhead. Tracing instruments method entry/exit and captures exact call counts. The profiler has a setting to exclude samples taken during JIT compilation, and profiling can be delayed relative to application start.
Likely explanation, not verified. The ~10 000 calls/second threshold and >20% inflation figure are empirical guidelines based on typical HotSpot behavior. Actual distortion varies with JVM version, hardware, workload, and method size. The default sampling interval is commonly described as ~1 kµs, which makes early samples sensitive to warm-up. The effectiveness of "Ignore JIT compilation" and a 30 s warm-up is workload dependent.
Assumptions: you are using the integrated IntelliJ IDEA Profiler with the standard HotSpot JVM backend. Uncertainty remains on exact threshold for your workload; verification on your application is required.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.