</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></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="begin-or-end-profiling-when-function-is-executed"tabindex="-1"><aclass="header-anchor"href="#begin-or-end-profiling-when-function-is-executed"aria-hidden="true">#</a> Begin or end profiling when FUNCTION is executed</h2><p>Use <code>--begin function</code> and <code>--end function</code> to automatically start/stop profiling when the specified native function is executed. Its main purpose is to profile certain JVM phases like GC and Safepoint pauses. You should use native function name defined in a JVM implement, for example <code>SafepointSynchronize::begin</code> and <code>SafepointSynchronize::end</code> 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 <code>--ttsp</code> option is an alias for <code>--begin SafepointSynchronize::begin --end RuntimeService::record_safepoint_synchronized</code>. It is not a separate event type, but rather a constraint. Whatever event type you choose (e.g. cpu or wall), the profiler will work as usual, except that only events between the safepoint request and the start of the VM operation will be recorded.</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><h2id="use-events-from-profiler-for-java-flight-recording"tabindex="-1"><aclass="header-anchor"href="#use-events-from-profiler-for-java-flight-recording"aria-hidden="true">#</a> Use events from profiler for Java Flight Recording</h2><p>Use <code>--jfrsync CONFIG</code> to start Java Flight Recording with the given configuration synchronously with the profiler. The output .jfr file will include all regular JFR events, except that execution samples will be obtained from async-profiler. This option implies -o jfr.</p><p><code>CONFIG</code> can be <code>profile</code>, means using the predefined JFR config "profile" in <code>$JAVA_HOME/lib/jfr/</code>, or full path of a JFR configuration file (.jfc), this value has the same format with <ahref="https://docs.oracle.com/en/java/javase/17/docs/specs/man/jcmd.html"target="_blank"rel="noopener noreferrer">settings option of JFR.start<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><p>For example, command below use "profile" config of JFR:</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><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></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: 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>