mirror of https://github.com/alibaba/arthas.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
14 KiB
JavaScript
54 lines
14 KiB
JavaScript
import{_ as n,a as r}from"./arthas-output-svg.39442da8.js";import{_ as l,o,c as d,a as e,b as t,e as s,d as i,r as c}from"./app.6c27e557.js";const u={},p=e("h1",{id:"profiler",tabindex:"-1"},[e("a",{class:"header-anchor",href:"#profiler","aria-hidden":"true"},"#"),s(" profiler")],-1),h={href:"https://arthas.aliyun.com/doc/arthas-tutorials.html?language=en&id=command-profiler",target:"_blank",rel:"noopener noreferrer"},m=e("code",null,"profiler",-1),f=s(" online tutorial"),v={class:"custom-container tip"},b=e("p",{class:"custom-container-title"},"TIP",-1),g=s("Generate a flame graph using "),x={href:"https://github.com/jvm-profiling-tools/async-profiler",target:"_blank",rel:"noopener noreferrer"},_=s("async-profiler"),y=i(`<p>The <code>profiler</code> command supports generate flame graph for application hotspots.</p><p>The basic usage of the <code>profiler</code> command is <code>profiler action [actionArg]</code></p><h2 id="supported-options" tabindex="-1"><a class="header-anchor" href="#supported-options" aria-hidden="true">#</a> Supported Options</h2><table><thead><tr><th style="text-align:right;">Name</th><th style="text-align:left;">Specification</th></tr></thead><tbody><tr><td style="text-align:right;"><em>action</em></td><td style="text-align:left;">Action to execute</td></tr><tr><td style="text-align:right;"><em>actionArg</em></td><td style="text-align:left;">Attribute name pattern</td></tr><tr><td style="text-align:right;">[i:]</td><td style="text-align:left;">sampling interval in ns (default: 10'000'000, i.e. 10 ms)</td></tr><tr><td style="text-align:right;">[f:]</td><td style="text-align:left;">dump output to specified directory</td></tr><tr><td style="text-align:right;">[d:]</td><td style="text-align:left;">run profiling for specified seconds</td></tr><tr><td style="text-align:right;">[e:]</td><td style="text-align:left;">which event to trace (cpu, alloc, lock, cache-misses etc.), default value is cpu</td></tr></tbody></table><h2 id="start-profiler" tabindex="-1"><a class="header-anchor" href="#start-profiler" aria-hidden="true">#</a> Start profiler</h2><div class="language-text ext-text line-numbers-mode"><pre class="language-text"><code>$ profiler start
|
|
Started [cpu] profiling
|
|
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><div class="custom-container tip"><p class="custom-container-title">TIP</p><p>By default, the sample event is <code>cpu</code>. Can be specified with the <code>--event</code> parameter.</p></div><h2 id="get-the-number-of-samples-collected" tabindex="-1"><a class="header-anchor" href="#get-the-number-of-samples-collected" aria-hidden="true">#</a> Get the number of samples collected</h2><div class="language-text ext-text line-numbers-mode"><pre class="language-text"><code>$ profiler getSamples
|
|
23
|
|
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="view-profiler-status" tabindex="-1"><a class="header-anchor" href="#view-profiler-status" aria-hidden="true">#</a> View profiler status</h2><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ profiler status
|
|
<span class="token punctuation">[</span>cpu<span class="token punctuation">]</span> profiling is running <span class="token keyword">for</span> <span class="token number">4</span> seconds
|
|
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><p>Can view which <code>event</code> and sampling time.</p><h2 id="stop-profiler" tabindex="-1"><a class="header-anchor" href="#stop-profiler" aria-hidden="true">#</a> Stop profiler</h2><h3 id="generating-html-format-results" tabindex="-1"><a class="header-anchor" href="#generating-html-format-results" aria-hidden="true">#</a> Generating html format results</h3><p>By default, the result file is <code>html</code> format. You can also specify it with the <code>--format</code> parameter:</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ profiler stop <span class="token parameter variable">--format</span> html
|
|
profiler output file: /tmp/test/arthas-output/20211207-111550.html
|
|
OK
|
|
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>Or use the file name name format in the <code>--file</code> parameter. For example, <code>--file /tmp/result.html</code>.</p><h2 id="view-profiler-results-under-arthas-output-via-browser" tabindex="-1"><a class="header-anchor" href="#view-profiler-results-under-arthas-output-via-browser" aria-hidden="true">#</a> View profiler results under arthas-output via browser</h2>`,18),k=s("By default, arthas uses port 3658, which can be opened: "),w={href:"http://localhost:3658/arthas-output/",target:"_blank",rel:"noopener noreferrer"},S=s("http://localhost:3658/arthas-output/"),j=s(" View the "),T=e("code",null,"arthas-output",-1),I=s(" directory below Profiler results:"),B=i('<p><img src="'+n+'" alt=""></p><p>Click to view specific results:</p><p><img src="'+r+`" alt=""></p><div class="custom-container tip"><p class="custom-container-title">TIP</p><p>If using the chrome browser, may need to be refreshed multiple times.</p></div><h2 id="profiler-supported-events" tabindex="-1"><a class="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><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ profiler list
|
|
Basic events:
|
|
cpu
|
|
alloc
|
|
lock
|
|
wall
|
|
itimer
|
|
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>Under linux</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ profiler list
|
|
Basic events:
|
|
cpu
|
|
alloc
|
|
lock
|
|
wall
|
|
itimer
|
|
Perf events:
|
|
page-faults
|
|
context-switches
|
|
cycles
|
|
instructions
|
|
cache-references
|
|
cache-misses
|
|
branches
|
|
branch-misses
|
|
bus-cycles
|
|
L1-dcache-load-misses
|
|
LLC-load-misses
|
|
dTLB-load-misses
|
|
mem:breakpoint
|
|
trace:tracepoint
|
|
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div>`,9),C=s("If you encounter the permissions/configuration issues of the OS itself and then missing some events, you can refer to the "),P={href:"https://github.com/jvm-profiling-tools/async-profiler",target:"_blank",rel:"noopener noreferrer"},$=s("async-profiler"),V=s(" documentation."),A=i(`<p>You can use the <code>--event</code> parameter to specify the event to sample, such as sampling the <code>alloc</code> event:</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ profiler start <span class="token parameter variable">--event</span> alloc
|
|
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h2 id="resume-sampling" tabindex="-1"><a class="header-anchor" href="#resume-sampling" aria-hidden="true">#</a> Resume sampling</h2><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ profiler resume
|
|
Started <span class="token punctuation">[</span>cpu<span class="token punctuation">]</span> profiling
|
|
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><p>The difference between <code>start</code> and <code>resume</code> is: <code>start</code> is the new start sampling, <code>resume</code> will retain the data of the last <code>stop</code>.</p><p>You can verify the number of samples by executing <code>profiler getSamples</code>.</p><h2 id="use-execute-action-to-execute-complex-commands" tabindex="-1"><a class="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><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler execute <span class="token string">'start,framebuf=5000000'</span>
|
|
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>Stop sampling and save to the specified file:</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler execute <span class="token string">'stop,file=/tmp/result.html'</span>
|
|
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div>`,11),L=s("Specific format reference: "),N={href:"https://github.com/jvm-profiling-tools/async-profiler/blob/v2.5/src/arguments.cpp#L50",target:"_blank",rel:"noopener noreferrer"},F=s("arguments.cpp"),O=i(`<h2 id="view-all-supported-actions" tabindex="-1"><a class="header-anchor" href="#view-all-supported-actions" aria-hidden="true">#</a> View all supported actions</h2><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ profiler actions
|
|
Supported Actions: <span class="token punctuation">[</span>resume, dumpCollapsed, getSamples, start, list, execute, version, stop, load, dumpFlat, actions, dumpTraces, status<span class="token punctuation">]</span>
|
|
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="view-version" tabindex="-1"><a class="header-anchor" href="#view-version" aria-hidden="true">#</a> View version</h2><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ profiler version
|
|
Async-profiler <span class="token number">1.6</span> built on Sep <span class="token number">9</span> <span class="token number">2019</span>
|
|
Copyright <span class="token number">2019</span> Andrei Pangin
|
|
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="configure-framebuf-option" tabindex="-1"><a class="header-anchor" href="#configure-framebuf-option" aria-hidden="true">#</a> Configure framebuf option</h2><div class="custom-container tip"><p class="custom-container-title">TIP</p><p>you encounter <code>[frame_buffer_overflow]</code> in the generated result, you need to increase the framebuf (the default value is 1'000'000), which can be configured explicitly, such as:</p></div><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler start <span class="token parameter variable">--framebuf</span> <span class="token number">5000000</span>
|
|
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h2 id="configure-include-exclude-to-filter-data" tabindex="-1"><a class="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 the data, you can filter by include/exclude. such as</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler start --include<span class="token string">'java/*'</span> --include<span class="token string">'demo/*'</span> --exclude<span class="token string">'*Unsafe.park*'</span>
|
|
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><blockquote><p>Both include/exclude support setting multiple values, but need to be configured at the end of the command line.</p></blockquote><h2 id="specify-execution-time" tabindex="-1"><a class="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:</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler start <span class="token parameter variable">--duration</span> <span class="token number">300</span>
|
|
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h2 id="generate-jfr-format-result" tabindex="-1"><a class="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><div class="language-text ext-text line-numbers-mode"><pre class="language-text"><code>profiler start --file /tmp/test.jfr
|
|
</code></pre><div class="line-numbers" aria-hidden="true"><div class="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><h2 id="the-unknown-in-profiler-result" tabindex="-1"><a class="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>`,23);function q(G,U){const a=c("ExternalLinkIcon");return o(),d("div",null,[p,e("p",null,[e("a",h,[m,f,t(a)])]),e("div",v,[b,e("p",null,[g,e("a",x,[_,t(a)])])]),y,e("p",null,[k,e("a",w,[S,t(a)]),j,T,I]),B,e("p",null,[C,e("a",P,[$,t(a)]),V]),A,e("p",null,[L,e("a",N,[F,t(a)])]),O])}const D=l(u,[["render",q],["__file","profiler.html.vue"]]);export{D as default};
|