</script><metaname="aes-config"content="pid=xux-opensource&user_type=101&uid=&username=&dim10=arthas"><scriptsrc="//g.alicdn.com/alilog/mlog/aplus_v2.js"id="beacon-aplus"exparams="clog=o&aplus&sidx=aplusSidx&ckx=aplusCkx"></script><scriptsrc="//g.alicdn.com/aes/??tracker/1.0.34/index.js,tracker-plugin-pv/2.4.5/index.js,tracker-plugin-event/1.2.5/index.js,tracker-plugin-jserror/1.0.13/index.js,tracker-plugin-api/1.1.14/index.js,tracker-plugin-perf/1.1.8/index.js,tracker-plugin-eventTiming/1.0.4/index.js"></script><title>profiler | arthas</title><metaname="description"content="arthas user document">
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div><divclass="line-number"></div></div></div><divclass="custom-container tip"><pclass="custom-container-title">TIP</p><p>By default, the sample event is <code>cpu</code>. Other valid profiling modes can be specified with the <code>--event</code> parameter, see relevant contents below.</p></div><h2id="get-the-number-of-samples-collected"tabindex="-1"><aclass="header-anchor"href="#get-the-number-of-samples-collected"aria-hidden="true">#</a> Get the number of samples collected</h2><divclass="language-text ext-text line-numbers-mode"><preclass="language-text"><code>$ profiler getSamples
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div><divclass="line-number"></div></div></div><p>Can view which <code>event</code> and sampling time.</p><h2id="view-profiler-memory-usage"tabindex="-1"><aclass="header-anchor"href="#view-profiler-memory-usage"aria-hidden="true">#</a> View profiler memory usage</h2><divclass="language-text ext-text line-numbers-mode"><preclass="language-text"><code>$ profiler meminfo
Call trace storage: 10244 KB
Dictionaries: 72 KB
Code cache: 12890 KB
------------------------------
Total: 23206 KB
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div></div></div><h2id="stop-profiler"tabindex="-1"><aclass="header-anchor"href="#stop-profiler"aria-hidden="true">#</a> Stop profiler</h2><h3id="generating-flame-graph-results"tabindex="-1"><aclass="header-anchor"href="#generating-flame-graph-results"aria-hidden="true">#</a> Generating flame graph results</h3><p>By default, the result file is <code>html</code> file in <ahref="https://github.com/BrendanGregg/FlameGraph"target="_blank"rel="noopener noreferrer">Flame Graph<span><svgclass="external-link-icon"xmlns="http://www.w3.org/2000/svg"aria-hidden="true"focusable="false"x="0px"y="0px"viewbox="0 0 100 100"width="15"height="15"><pathfill="currentColor"d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygonfill="currentColor"points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><spanclass="external-link-icon-sr-only">open in new window</span></span></a> format. You can also specify other format with the <code>-o</code> or <code>--format</code> parameter, including flat, traces, collapsed, flamegraph, tree, jfr:</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>$ profiler stop <spanclass="token parameter variable">--format</span> flamegraph
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div></div></div><p>When extension of filename in <code>--file</code> parameter is <code>html</code> or <code>jfr</code>, the output format can be infered. For example, <code>--file /tmp/result.html</code> will generate flamegraph automatically.</p><h2id="view-profiler-results-under-arthas-output-via-browser"tabindex="-1"><aclass="header-anchor"href="#view-profiler-results-under-arthas-output-via-browser"aria-hidden="true">#</a> View profiler results under arthas-output via browser</h2><p>By default, arthas uses port 3658, which can be opened: <ahref="http://localhost:3658/arthas-output/"target="_blank"rel="noopener noreferrer">http://localhost:3658/arthas-output/<span><svgclass="external-link-icon"xmlns="http://www.w3.org/2000/svg"aria-hidden="true"focusable="false"x="0px"y="0px"viewbox="0 0 100 100"width="15"height="15"><pathfill="currentColor"d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygonfill="currentColor"points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><spanclass="external-link-icon-sr-only">open in new window</span></span></a> View the <code>arthas-output</code> directory below Profiler results:</p><p><imgsrc="/images/arthas-output.jpg"alt=""></p><p>Click to view specific results:</p><p><imgsrc="/images/arthas-output-svg.jpg"alt=""></p><divclass="custom-container tip"><pclass="custom-container-title">TIP</p><p>If using the chrome browser, may need to be refreshed multiple times.</p></div><h2id="profiler-supported-events"tabindex="-1"><aclass="header-anchor"href="#profiler-supported-events"aria-hidden="true">#</a> Profiler supported events</h2><p>Under different platforms and different OSs, the supported events are different. For example, under macos:</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>$ profiler list
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div></div></div><p>If you encounter the permissions/configuration issues of the OS itself and then missing some events, you can refer to the <ahref="https://github.com/jvm-profiling-tools/async-profiler"target="_blank"rel="noopener noreferrer">async-profiler<span><svgclass="external-link-icon"xmlns="http://www.w3.org/2000/svg"aria-hidden="true"focusable="false"x="0px"y="0px"viewbox="0 0 100 100"width="15"height="15"><pathfill="currentColor"d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygonfill="currentColor"points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><spanclass="external-link-icon-sr-only">open in new window</span></span></a> documentation.</p><p>You can use <code>check</code> action to check if a profiling event is available, this action receives the same format options with <code>start</code>.</p><p>You can use the <code>--event</code> parameter to specify the event to sample, for example, <code>alloc</code> event means heap memory allocation profiling:</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>$ profiler start <spanclass="token parameter variable">--event</span> alloc
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div><divclass="line-number"></div></div></div><p>The difference between <code>start</code> and <code>resume</code> is: <code>start</code> will clean existing result of last profiling before starting, <code>resume</code> will retain the existing result and add result of this time to it.</p><p>You can verify the number of samples by executing <code>profiler getSamples</code>.</p><h2id="dump-action"tabindex="-1"><aclass="header-anchor"href="#dump-action"aria-hidden="true">#</a> Dump action</h2><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>$ profiler dump
OK
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div><divclass="line-number"></div></div></div><p>The <code>dump</code> action saves profiling result to default file or specified file, but profiling will continue. That means if you start profiling and dump after 5 seconds, then dump after 2 seconds again, you will get 2 result files, the first one contains profiling result of 0~5 seconds and the second one contains that of 0~7 seconds.</p><h2id="use-execute-action-to-execute-complex-commands"tabindex="-1"><aclass="header-anchor"href="#use-execute-action-to-execute-complex-commands"aria-hidden="true">#</a> Use <code>execute</code> action to execute complex commands</h2><p>For example, start sampling:</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>profiler execute <spanclass="token string">'start,framebuf=5000000'</span>
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div></div></div><p>Stop sampling and save to the specified file:</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>profiler execute <spanclass="token string">'stop,file=/tmp/result.html'</span>
Async-profiler <spanclass="token number">2.9</span> built on May <spanclass="token number">8</span><spanclass="token number">2023</span>
Copyright <spanclass="token number">2016</span>-2021 Andrei Pangin
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div></div></div><h2id="configure-java-stack-depth"tabindex="-1"><aclass="header-anchor"href="#configure-java-stack-depth"aria-hidden="true">#</a> Configure Java stack depth</h2><p>You can use <code>-j</code> or <code>--jstackdepth</code> option to configure maximum Java stack depth. This option will be ignored if value is greater than default 2048. This option is useful when you don't want to see stacks that are too deep. Below is usage example:</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>profiler start <spanclass="token parameter variable">-j</span><spanclass="token number">256</span>
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div></div></div><h2id="profiling-different-threads-separately"tabindex="-1"><aclass="header-anchor"href="#profiling-different-threads-separately"aria-hidden="true">#</a> Profiling different threads separately</h2><p>You can use <code>-t</code> or <code>--threads</code> flag option to profile different threads separately, each stack trace will end with a frame that denotes a single thread.</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>profiler start <spanclass="token parameter variable">-t</span>
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div></div></div><h2id="configure-include-exclude-to-filter-data"tabindex="-1"><aclass="header-anchor"href="#configure-include-exclude-to-filter-data"aria-hidden="true">#</a> Configure include/exclude to filter data</h2><p>If the application is complex and generates a lot of content, and you want to focus on only part of stack traces, you can filter stack traces by <code>--include/--exclude</code>. <code>--include</code> defines the name pattern that must be present in the stack traces, while <code>--exclude</code> is the pattern that must not occur in any of stack traces in the output.A pattern may begin or end with a star <code>*</code> that denotes any (possibly empty) sequence of characters. such as</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>profiler stop --include<spanclass="token string">'java/*'</span><spanclass="token parameter variable">--include</span><spanclass="token string">'com/demo/*'</span> --exclude<spanclass="token string">'*Unsafe.park*'</span>
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div></div></div><blockquote><p>Both <code>--include/--exclude</code> support being set multiple times, but need to be configured at the end of the command line. You can also use short parameter format <code>-I/-X</code>. Note that <code>--include/--exclude</code> only supports configuration at <code>stop</code> action or <code>start</code> action with <code>-d</code>/<code>--duration</code> parameter, otherwise it will not take effect.</p></blockquote><h2id="specify-execution-time"tabindex="-1"><aclass="header-anchor"href="#specify-execution-time"aria-hidden="true">#</a> Specify execution time</h2><p>For example, if you want the profiler to automatically end after 300 seconds, you can specify it with the <code>-d</code>/<code>--duration</code> parameter in collect action:</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>profiler collect <spanclass="token parameter variable">--duration</span><spanclass="token number">300</span>
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div></div></div><h2id="generate-jfr-format-result"tabindex="-1"><aclass="header-anchor"href="#generate-jfr-format-result"aria-hidden="true">#</a> Generate jfr format result</h2><blockquote><p>Note that jfr only supports configuration at <code>start</code>. If it is specified at <code>stop</code>, it will not take effect.</p></blockquote><divclass="language-text ext-text line-numbers-mode"><preclass="language-text"><code>profiler start --file /tmp/test.jfr
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div><divclass="line-number"></div></div></div><p>The <code>file</code> parameter supports some variables:</p><ul><li>Timestamp: <code>--file /tmp/test-%t.jfr</code></li><li>Process ID: <code>--file /tmp/test-%p.jfr</code></li></ul><p>The generated results can be viewed with tools that support the jfr format. such as:</p><ul><li>JDK Mission Control: https://github.com/openjdk/jmc</li><li>JProfiler: https://github.com/alibaba/arthas/issues/1416</li></ul><h2id="control-details-in-result"tabindex="-1"><aclass="header-anchor"href="#control-details-in-result"aria-hidden="true">#</a> Control details in result</h2><p>The <code>-s</code> parameter will use simple name instead of Fully qualified name, e.g. <code>MathGame.main</code> instead of <code>demo.MathGame.main</code>. The <code>-g</code> parameter will use method signatures instead of method names, e.g. <code>demo.MathGame.main([Ljava/lang/String;)V</code> instead of <code>demo.MathGame.main</code>. There are many parameters related to result format details, you can refer to <ahref="https://github.com/async-profiler/async-profiler#readme"target="_blank"rel="noopener noreferrer">async-profiler README<span><svgclass="external-link-icon"xmlns="http://www.w3.org/2000/svg"aria-hidden="true"focusable="false"x="0px"y="0px"viewbox="0 0 100 100"width="15"height="15"><pathfill="currentColor"d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygonfill="currentColor"points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><spanclass="external-link-icon-sr-only">open in new window</span></span></a> and <ahref="https://github.com/async-profiler/async-profiler/discussions"target="_blank"rel="noopener noreferrer">async-profiler Github Discussions<span><svgclass="external-link-icon"xmlns="http://www.w3.org/2000/svg"aria-hidden="true"focusable="false"x="0px"y="0px"viewbox="0 0 100 100"width="15"height="15"><pathfill="currentColor"d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygonfill="currentColor"points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><spanclass="external-link-icon-sr-only">open in new window</span></span></a> and other information.</p><p>For example, in command below, <code>-s</code> use simple name for Java class, <code>-g</code> show method signatures, <code>-a</code> will annotate Java methods, <code>-l</code> will prepend library names for native method, <code>--title</code> specify a title for flame graph page, <code>--minwidth</code> will skip frames smaller than 15% in flame graph, <code>--reverse</code> will generate stack-reversed FlameGraph / Call tree.</p><divclass="language-text ext-text line-numbers-mode"><preclass="language-text"><code>profiler stop -s -g -a -l --title <flametitle> --minwidth 15 --reverse
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div></div></div><h2id="the-unknown-in-profiler-result"tabindex="-1"><aclass="header-anchor"href="#the-unknown-in-profiler-result"aria-hidden="true">#</a> The 'unknown' in profiler result</h2><ul><li>https://github.com/jvm-profiling-tools/async-profiler/discussions/409</li></ul><h2id="config-locks-allocations-profiling-threshold"tabindex="-1"><aclass="header-anchor"href="#config-locks-allocations-profiling-threshold"aria-hidden="true">#</a> Config locks/allocations profiling threshold</h2><p>When profiling in locks or allocations event, you can use <code>--lock</code> or <code>--alloc</code> to config thresholds, for example:</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>profiler start <spanclass="token parameter variable">-e</span> lock <spanclass="token parameter variable">--lock</span> 10ms
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div><divclass="line-number"></div></div></div><p>will profile contended locks longer than 10ms (default unit is ns if no unit is specified), or profile allocations with 2m BYTES interval.</p><h2id="config-jfr-chunks"tabindex="-1"><aclass="header-anchor"href="#config-jfr-chunks"aria-hidden="true">#</a> Config JFR chunks</h2><p>When using JFR as output format, you can use <code>--chunksize</code> or <code>--chunktime</code> to config approximate size (in bytes, default value is 100MB) and time limits (default value is 1 hour) for a single JFR chunk. For example:</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>profiler start <spanclass="token parameter variable">-f</span> profile.jfr <spanclass="token parameter variable">--chunksize</span> 100m <spanclass="token parameter variable">--chunktime</span> 1h
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div></div></div><h2id="group-threads-by-scheduling-policy"tabindex="-1"><aclass="header-anchor"href="#group-threads-by-scheduling-policy"aria-hidden="true">#</a> Group threads by scheduling policy</h2><p>You can use <code>--sched</code> flag option to group threads in output by Linux-specific scheduling policy: BATCH/IDLE/OTHER, for example:</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>profiler start <spanclass="token parameter variable">--sched</span>
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div></div></div><p>The second line from bottom in flamegraph represent the scheduling policy.</p><h2id="build-allocation-profile-from-live-objects-only"tabindex="-1"><aclass="header-anchor"href="#build-allocation-profile-from-live-objects-only"aria-hidden="true">#</a> Build allocation profile from live objects only</h2><p>Use <code>--live</code> flag option to retain allocation samples with live objects only (object that have not been collected by the end of profiling session). Useful for finding Java heap memory leaks.</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>profiler start <spanclass="token parameter variable">--live</span>
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div></div></div><h2id="config-method-of-collecting-c-stack-frames"tabindex="-1"><aclass="header-anchor"href="#config-method-of-collecting-c-stack-frames"aria-hidden="true">#</a> Config method of collecting C stack frames</h2><p>Use <code>--cstack MODE</code> to config how to walk native frames (C stack). Possible modes are fp (Frame Pointer), dwarf (DWARF unwind info), lbr (Last Branch Record, available on Haswell since Linux 4.1), and no (do not collect C stack).</p><p>By default, C stack is shown in cpu, itimer, wall-clock and perf-events profiles. Java-level events like alloc and lock collect only Java stack.</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>profiler <spanclass="token parameter variable">--cstack</span> fp
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div></div></div><p>The command above will collection Frame Pointer of C stacks.</p><h2id="start-stop-profiling-when-a-specified-native-function-is-executed"tabindex="-1"><aclass="header-anchor"href="#start-stop-profiling-when-a-specified-native-function-is-executed"aria-hidden="true">#</a> Start/Stop Profiling When a Specified Native Function is Executed</h2><p>Using the <code>--begin function</code> and <code>--end function</code> options, you can start or stop profiling when a specified native function is executed. The main use is to analyze specific JVM phases, such as GC and Safepoint. You need to use the native function names in the specific JVM implementation, such as SafepointSynchronize::begin and SafepointSynchronize::end in HotSpot JVM.</p><h3id="time-to-safepoint-profiling"tabindex="-1"><aclass="header-anchor"href="#time-to-safepoint-profiling"aria-hidden="true">#</a> Time-to-Safepoint Profiling</h3><p>The option <code>--ttsp</code> is actually an alias for <code>--begin SafepointSynchronize::begin --end RuntimeService::record_safepoint_synchronized</code>. It is a constraint, not a separate event type. The Profiler will work regardless of which event is selected, but only events between VM operations and Safepoint requests will be recorded.</p><p><code>profiler</code> now automatically includes profiler.Window events in the generated JFR file when the <code>--ttsp</code> option is used and a JFR output format is specified. These events represent the time interval of each Time-to-Safepoint pause, allowing you to analyze these pauses without relying on JVM logs.</p><p>Example</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>profiler start <spanclass="token parameter variable">--begin</span> SafepointSynchronize::begin <spanclass="token parameter variable">--end</span> RuntimeService::record_safepoint_synchronized
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div><divclass="line-number"></div></div></div><p>The generated JFR file will contain profiler.Window events, which can be viewed and analyzed using tools such as JDK Mission Control.</p><p><strong>Notes:</strong></p><ul><li><p>profiler.Window events are generic events that apply to any time window using the --begin and --end triggers, not just Safepoint pauses.</p></li><li><p>When analyzing long Safepoint pauses, profiler.Window events can help you identify the cause of delays.</p></li><li><p>When using the --ttsp option, make sure to use the JFR output format so that profiler.Window events can be generated and viewed.</p></li></ul><h2id="generate-jfr-file-using-events-recorded-by-profiler"tabindex="-1"><aclass="header-anchor"href="#generate-jfr-file-using-events-recorded-by-profiler"aria-hidden="true">#</a> Generate JFR file using events recorded by profiler</h2><p>Use <code>--jfrsync CONFIG</code> option to specify configuration to start Java Flight Recording. The output jfr file will contain all normal JFR events, but the sampling sources are provided by the profiler.</p><p>CONFIG parameters:</p><ul><li><p>Preset configuration: CONFIG can be profile, which means to use the preset profile configuration in the $JAVA_HOME/lib/jfr directory.</p></li><li><p>Custom configuration file: CONFIG can also be a custom JFR configuration file (.jfc). The value of this option uses the same format as the settings option of the jcmd JFR.start command.</p></li><li><p>Specify a list of JFR events: Now, you can directly specify the list of JFR events to be enabled in --jfrsync without creating a .jfc file. To specify a list of events, start with + and separate multiple events with +.</p></li></ul><p>Example:</p><p>Start JFR with a preset profile configuration:</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>profiler start <spanclass="token parameter variable">-e</span> cpu <spanclass="token parameter variable">--jfrsync</span> profile <spanclass="token parameter variable">-f</span> combined.jfr
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div></div></div><p>Directly specify a list of JFR events, for example, to enable jdk.YoungGarbageCollection and jdk.OldGarbageCollection events:</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>profiler start <spanclass="token parameter variable">-e</span> cpu <spanclass="token parameter variable">--jfrsync</span> +jdk.YoungGarbageCollection+jdk.OldGarbageCollection <spanclass="token parameter variable">-f</span> combined.jfr
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div></div></div><p><strong>Notes</strong></p><ul><li>When specifying a list of events, events are separated by a plus sign + because commas , are used to separate different options.</li><li>If the --jfrsync parameter does not start with +, it is treated as a preset profile name or a path to a .jfc configuration file.</li><li>Directly specifying a list of events is particularly useful when the target application is running in a container, without additional file operations.</li></ul><h2id="run-profiler-in-a-loop"tabindex="-1"><aclass="header-anchor"href="#run-profiler-in-a-loop"aria-hidden="true">#</a> Run profiler in a loop</h2><p>Use <code>--loop TIME</code> to run profiler in a loop (continuous profiling). The argument is either a clock time (hh:mm:ss) or a loop duration in seconds, minutes, hours, or days. Make sure the filename includes a timestamp pattern, or the output will be overwritten on each iteration. The command below will run profiling endlessly and save records of each hour to a jfr file.</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>profiler start <spanclass="token parameter variable">--loop</span> 1h <spanclass="token parameter variable">-f</span> /var/log/profile-%t.jfr
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div></div></div><h2id="timeout-option"tabindex="-1"><aclass="header-anchor"href="#timeout-option"aria-hidden="true">#</a><code>--timeout</code> option</h2><p>This option specifies the time when profiling will automatically stop. The format is the same as in loop: it is either a wall clock time (12:34:56) or a relative time interval (2h).</p><p>Both <code>--loop</code> and <code>--timeout</code> are used for <code>start</code> action but not for <code>collect</code> action, for further information refer to <ahref="https://github.com/async-profiler/async-profiler/discussions/789"target="_blank"rel="noopener noreferrer">async-profiler Github Discussions<span><svgclass="external-link-icon"xmlns="http://www.w3.org/2000/svg"aria-hidden="true"focusable="false"x="0px"y="0px"viewbox="0 0 100 100"width="15"height="15"><pathfill="currentColor"d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygonfill="currentColor"points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><spanclass="external-link-icon-sr-only">open in new window</span></span></a>.</p><h2id="wall-option"tabindex="-1"><aclass="header-anchor"href="#wall-option"aria-hidden="true">#</a><code>--wall</code> option</h2><p>The -- wall option allows for simultaneous performance analysis of both CPU and Wall Clock. This joint analysis helps to more comprehensively identify and understand performance bottlenecks in applications. --The wall option allows users to set the sampling interval for Wall Clock analysis independently of CPU analysis. For example, by setting - e cpu-i 10-- wall 200, the CPU sampling interval can be set to 10 milliseconds, and the wall clock sampling interval can be set to 200 milliseconds. When conducting joint CPU and Wall Clock analysis, the output format must be set to jfr. This format supports recording the state information of threads (such as State_SUNNABLE or State_SLEEPING) to distinguish between different types of sampling events.</p><p>influence Linux platform: This new feature is only available on the Linux platform. The CPU analysis engine on macOS is already based on Wall clock mode, so there are no additional benefits. Performance overhead: Enabling Wall clock analysis will increase performance overhead, so when analyzing both CPU and Wall clock simultaneously, it is recommended to increase the interval between Wall clocks.</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>profiler start <spanclass="token parameter variable">-e</span> cpu <spanclass="token parameter variable">-i</span><spanclass="token number">10</span><spanclass="token parameter variable">--wall</span><spanclass="token number">100</span><spanclass="token parameter variable">-f</span> out.jfr
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div></div></div><h2id="ctimer-events"tabindex="-1"><aclass="header-anchor"href="#ctimer-events"aria-hidden="true">#</a><code>ctimer</code> events</h2><p><code>ctimer</code> events are a new CPU sampling mode based on <code>timer_create</code>, providing accurate CPU sampling without <code>perf_events</code>.</p><p>In some cases, <code>perf_events</code> may not be available, for example due to <code>perf_event_paranoid</code> settings or <code>seccomp</code> restrictions, or in container environments. Although itimer events can work in containers, there may be sampling inaccuracies.</p><p><code>ctimer</code> events combine the advantages of <code>cpu</code> and <code>itimer</code>:</p><ul><li><p>High accuracy: provides accurate CPU sampling.</p></li><li><p>Container-friendly: available in containers by default.</p></li><li><p>Low resource consumption: does not consume file descriptors.</p></li></ul><p>**Note that <code>ctimer</code> events are currently only supported on <code>Linux</code>, not <code>macOS</code>. ** See <ahref="https://github.com/async-profiler/async-profiler/issues/855"target="_blank"rel="noopener noreferrer">async-profiler Github Issues<span><svgclass="external-link-icon"xmlns="http://www.w3.org/2000/svg"aria-hidden="true"focusable="false"x="0px"y="0px"viewbox="0 0 100 100"width="15"height="15"><pathfill="currentColor"d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygonfill="currentColor"points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><spanclass="external-link-icon-sr-only">open in new window</span></span></a> for more information.</p><p>Example:</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>profiler start <spanclass="token parameter variable">-e</span> ctimer <spanclass="token parameter variable">-o</span> jfr <spanclass="token parameter variable">-f</span> ./out-test.jfr
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div></div></div><h2id="vtable-feature"tabindex="-1"><aclass="header-anchor"href="#vtable-feature"aria-hidden="true">#</a><code>vtable</code> Feature</h2><p>In some applications, a lot of CPU time is spent in calling <code>megamorphic</code> virtual or interface methods, which is shown as <code>vtable stub</code> or <code>itable stub</code> in performance analysis. This does not help us understand why a specific call site is <code>megamorphic</code> and how to optimize it.</p><p>The vtable feature can add a pseudo frame on top of the <code>vtable stub</code> or <code>itable stub</code>, showing the actual object type being called. This helps to clearly understand the ratio of different receivers at a specific call site.</p><p>This feature is disabled by default and can be enabled with the <code>-F vtable</code> option (or using <code>features=vtable</code>). See the <ahref="https://github.com/async-profiler/async-profiler/issues/736"target="_blank"rel="noopener noreferrer">async-profiler Github Issues<span><svgclass="external-link-icon"xmlns="http://www.w3.org/2000/svg"aria-hidden="true"focusable="false"x="0px"y="0px"viewbox="0 0 100 100"width="15"height="15"><pathfill="currentColor"d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygonfill="currentColor"points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><spanclass="external-link-icon-sr-only">open in new window</span></span></a> for more information.</p><p>Example:</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>profiler start <spanclass="token parameter variable">-F</span> vtable
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div></div></div><h2id="comptask-feature"tabindex="-1"><aclass="header-anchor"href="#comptask-feature"aria-hidden="true">#</a><code>comptask</code> feature</h2><p><code>profiler</code> samples the JIT compiler threads as well as the Java threads, and can show the percentage of CPU consumed by JIT compilation. However, the compilation resource consumption of Java methods varies, and it is useful to know which specific Java methods consume the most CPU time when compiling.</p><p>The <code>comptask</code> feature adds a virtual frame to the stack trace of <code>C1/C2</code>, showing the current task being compiled, that is, the Java method being compiled.</p><p>This feature is disabled by default and can be enabled with the <code>-F comptask</code> option (or using <code>features=comptask</code>). See <ahref="https://github.com/async-profiler/async-profiler/issues/777"target="_blank"rel="noopener noreferrer">async-profiler Github Issues<span><svgclass="external-link-icon"xmlns="http://www.w3.org/2000/svg"aria-hidden="true"focusable="false"x="0px"y="0px"viewbox="0 0 100 100"width="15"height="15"><pathfill="currentColor"d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygonfill="currentColor"points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><spanclass="external-link-icon-sr-only">open in new window</span></span></a> for more information.</p><p>Example:</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>profiler start <spanclass="token parameter variable">-F</span> comptask
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div></div></div><h2id="configuring-alternative-profiling-signals"tabindex="-1"><aclass="header-anchor"href="#configuring-alternative-profiling-signals"aria-hidden="true">#</a> Configuring Alternative Profiling Signals</h2><p><code>profiler</code> uses <code>POSIX</code> signals for performance profiling. By default, <code>SIGPROF</code> is used for <code>CPU</code> profiling and <code>SIGVTALRM</code> is used for <code>Wall-Clock</code> profiling. However, this can lead to signal conflicts if your application also uses these signals or if you want to run multiple <code>profiler</code> instances simultaneously.</p><p>You can now use the <code>signal</code> parameter to configure the signal used for profiling to avoid conflicts.</p><p>See <ahref="https://github.com/async-profiler/async-profiler/issues/759"target="_blank"rel="noopener noreferrer">async-profiler Github Issues<span><svgclass="external-link-icon"xmlns="http://www.w3.org/2000/svg"aria-hidden="true"focusable="false"x="0px"y="0px"viewbox="0 0 100 100"width="15"height="15"><pathfill="currentColor"d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygonfill="currentColor"points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><spanclass="external-link-icon-sr-only">open in new window</span></span></a> for more information.</p><p>Syntax</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>profiler start <spanclass="token parameter variable">--signal</span><spanclass="token operator"><</span>signal number<spanclass="token operator">></span>
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div></div></div><p>If you need to specify the signal for CPU and Wall-Clock analysis separately, you can use the following syntax:</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>profiler start <spanclass="token parameter variable">--signal</span><spanclass="token operator"><</span>CPU signal number<spanclass="token operator">></span>/<spanclass="token operator"><</span>Wall signal number<spanclass="token operator">></span>
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div></div></div><h2id="clock-option"tabindex="-1"><aclass="header-anchor"href="#clock-option"aria-hidden="true">#</a><code>--clock</code> option</h2><p>The <code>--clock</code> option allows the user to control the clock source used for sampling timestamps. This is useful for scenarios where you need to align the timestamps of <code>profiler</code> data with data from other tools.</p><p>Usage</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>profiler start <spanclass="token parameter variable">--clock</span><spanclass="token operator"><</span>tsc<spanclass="token operator">|</span>monotonic<spanclass="token operator">></span>
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div></div></div><p>Parameters</p><ul><li><p><code>tsc</code>: Use the CPU's timestamp counter (<code>RDTSC</code>). This is the default option and provides high-precision timestamps.</p></li><li><p><code>monotonic</code>: Use the operating system's monotonic clock (<code>CLOCK_MONOTONIC</code>). This helps align timestamps between multiple data sources. See <ahref="https://github.com/async-profiler/async-profiler/issues/723"target="_blank"rel="noopener noreferrer">async-profiler Github Issues<span><svgclass="external-link-icon"xmlns="http://www.w3.org/2000/svg"aria-hidden="true"focusable="false"x="0px"y="0px"viewbox="0 0 100 100"width="15"height="15"><pathfill="currentColor"d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygonfill="currentColor"points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><spanclass="external-link-icon-sr-only">open in new window</span></span></a> for more information.</p></li></ul><p>Example:</p><p>Using <code>CLOCK_MONOTONIC</code> as timestamp source:</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>profiler start <spanclass="token parameter variable">--clock</span> monotonic
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div></div></div><p><strong>Notes:</strong></p><ul><li><p>Use <code>--clock monotonic</code> when you need to align <code>profiler</code> data with data from other tools that use <code>CLOCK_MONOTONIC</code> (e.g. <code>perf</code>).</p></li><li><p>Use <code>--clock</code> option with caution when using <code>jfrsync</code> mode, as the JVM and <code>profiler</code> may use different timestamp sources, which may lead to inconsistent results.</p></li></ul><h2id="norm-option"tabindex="-1"><aclass="header-anchor"href="#norm-option"aria-hidden="true">#</a><code>--norm</code> option</h2><p>In Java 20 and earlier, the method names generated by the compiler for <code>lambda</code> expressions contain a unique numeric suffix. For example, a <code>lambda</code> expression defined in the same code location may generate multiple different frame names, because each <code>lambda</code> method name is appended with a unique numeric suffix (such as <code>lambda$method$0</code>, <code>lambda$method$1</code>, etc.). This causes logically identical stacks to not be merged in the flame graph, increasing the complexity of performance analysis.</p><p>To solve this problem, <code>profiler</code> has added a <code>--norm</code> option that automatically normalizes method names when generating output, removes these numeric suffixes, and enables identical stacks to be merged correctly. Please refer to <ahref="https://github.com/async-profiler/async-profiler/issues/832"target="_blank"rel="noopener noreferrer">async-profiler Github Issues<span><svgclass="external-link-icon"xmlns="http://www.w3.org/2000/svg"aria-hidden="true"focusable="false"x="0px"y="0px"viewbox="0 0 100 100"width="15"height="15"><pathfill="currentColor"d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygonfill="currentColor"points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><spanclass="external-link-icon-sr-only">open in new window</span></span></a> for more information.</p><p><strong>Example:</strong></p><p>Generate a normalized flame graph:</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>profiler start <spanclass="token parameter variable">--norm</span>
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div></div></div></div><!--[--><!--]--></div><footerclass="page-meta right-menu-padding"data-v-fdd717e0><divclass="meta-item edit-link"><aclass="external-link meta-item-label"href="https://github.com/alibaba/arthas/edit/master/site/docs/en/doc/profiler.md"rel="noopener noreferrer"target="_blank"aria-label="Edit this page on GitHub"><!--[--><!--]--><span>Edit this page on GitHub</span><span><svgclass="external-link-icon"xmlns="http://www.w3.org/2000/svg"aria-hidden="true"focusable="false"x="0px"y="0px"viewbox="0 0 100 100"width="15"height="15"><pathfill="currentColor"d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygonfill="currentColor"points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><spanclass="external-link-icon-sr-only">open in new window</span></span><!--[--><!--]--></a></div><divclass="meta-item last-updated"><spanclass="meta-item-label">Last Updated: </span><!----></div><divclass="meta-item contributors"><spanclass="meta-item-label">Contributors: </span><spanclass="meta-item-info"><!--[--><!--[--><spanclass="contributor"title="email: wenchenghuang@mail.bnu.edu.cn">Winson Huang</span><!--[-->, <!--]--><!--]--><!--[--><spanclass="contributor"title="email: hengyunabc@gmail.com">hengyunabc</span><!--[-->, <!--]--><!--]--><!--[--><spanclass="contributor"title="email: 18235787078@163.com">CrazyCoder</span><!--[-->, <!--]--><!--]--><!--[--><spanclass="contributor"title="email: 68638598+Allan-QLB@users.noreply.github.com">Allan-QLB</span><!--[-->, <!--]--><!--]--><!--[--><spanclass="contributor"title="email: i@fatpandac.com">Fatpandac</span><!--[-->, <!--]--><!--]--><!--[--><spanclass="contributor"title="email: hengyunabc@users.noreply.github.com">hengyunabc</span><!--[-->, <!--]--><!--]--><!--[--><spanclass="contributor"title="email: 983433479@qq.com">汪吉</span><!--[-->, <!--]--><!--]--><!--[--><spanclass="contributor"title="email: hollowman186@vip.qq.com">Hollow Man</span><!----><!--]--><!--]--></span></div></footer><navclass="page-nav right-menu-padding"data-v-fdd717e0><pclass="inner"><spanclass="prev"><ahref="/en/doc/perfcounter.html"class=""aria-label="perfcounter"><!--[--><!--]--> perfcounter <!--[--><!--]--></a></span><spanclass="next"><ahref="/en/doc/pwd.html"class=""aria-label="pwd"><!--[--><!--]--> pwd <!--[--><!--]--></a></span></p></nav><!--[--><!--]--></main><!--]--></div><!----><!--]--></div>