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.
arthas/en/doc/profiler.html

133 lines
109 KiB
HTML

<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
3 years ago
<meta name="generator" content="VuePress 2.0.0-beta.51">
<style>
:root {
--c-bg: #fff;
}
html.dark {
--c-bg: #22272e;
}
html, body {
background-color: var(--c-bg);
}
</style>
<script>
const userMode = localStorage.getItem('vuepress-color-scheme');
const systemDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
if (userMode === 'dark' || (userMode !== 'light' && systemDarkMode)) {
document.documentElement.classList.toggle('dark', true);
}
</script>
3 years ago
<link rel="icon" href="/images/favicon.ico"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta property="og:title" content="Arthas"><meta property="og:image:alt" content="Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas - alibaba/arthas: Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas"><meta property="og:image" content="/images/arthas_mate_image.png"><meta property="og:description" content="Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas - alibaba/arthas: Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas"><meta property="og:image:width" content="1200"><meta property="og:image:height" content="600"><meta property="twitter:image:src" content="/images/arthas_mate_image.png"><meta property="twitter:image:alt" content="Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas - alibaba/arthas: Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas"><meta itemprop="name" content="Arthas"><meta itemprop="image" content="/images/arthas_mate_image.png"><meta itemprop="description" content="Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas - alibaba/arthas: Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas"><script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?d5c5e25b100f0eb51a4c35c8a86ea9b4";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
2 years ago
</script><meta name="aes-config" content="pid=xux-opensource&user_type=101&uid=&username=&dim10=arthas"><script src="//g.alicdn.com/alilog/mlog/aplus_v2.js" id="beacon-aplus" exparams="clog=o&aplus&sidx=aplusSidx&ckx=aplusCkx"></script><script src="//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><meta name="description" content="arthas user document">
5 months ago
<link rel="modulepreload" href="/assets/app.e05b0501.js"><link rel="modulepreload" href="/assets/profiler.html.cdcf2c7e.js"><link rel="modulepreload" href="/assets/arthas-output-svg.30f64f53.js"><link rel="modulepreload" href="/assets/profiler.html.24623d19.js"><link rel="prefetch" href="/assets/index.html.2733b79a.js"><link rel="prefetch" href="/assets/index.html.5db817a7.js"><link rel="prefetch" href="/assets/index.html.709f7507.js"><link rel="prefetch" href="/assets/advanced-use.html.5eabebbb.js"><link rel="prefetch" href="/assets/advice-class.html.1661f1b4.js"><link rel="prefetch" href="/assets/agent.html.4025a817.js"><link rel="prefetch" href="/assets/arthas-properties.html.0eb128f0.js"><link rel="prefetch" href="/assets/arthas3.html.7c7bcce9.js"><link rel="prefetch" href="/assets/async.html.decfb75b.js"><link rel="prefetch" href="/assets/auth.html.992a6d0f.js"><link rel="prefetch" href="/assets/base64.html.5593c3a1.js"><link rel="prefetch" href="/assets/batch-support.html.38b144b0.js"><link rel="prefetch" href="/assets/cat.html.3776c21f.js"><link rel="prefetch" href="/assets/classloader.html.bc7c7891.js"><link rel="prefetch" href="/assets/cls.html.001d9db7.js"><link rel="prefetch" href="/assets/commands.html.27371973.js"><link rel="prefetch" href="/assets/contact-us.html.31a7b417.js"><link rel="prefetch" href="/assets/dashboard.html.a5ef1740.js"><link rel="prefetch" href="/assets/docker.html.4196ff57.js"><link rel="prefetch" href="/assets/download.html.a10bf291.js"><link rel="prefetch" href="/assets/dump.html.604d5eb4.js"><link rel="prefetch" href="/assets/echo.html.1e462d2b.js"><link rel="prefetch" href="/assets/faq.html.9ab83ffb.js"><link rel="prefetch" href="/assets/getstatic.html.96639040.js"><link rel="prefetch" href="/assets/grep.html.0c64a5f8.js"><link rel="prefetch" href="/assets/groovy.html.55cdcaa3.js"><link rel="prefetch" href="/assets/heapdump.html.206a94e8.js"><link rel="prefetch" href="/assets/help.html.36fbfa1a.js"><link rel="prefetch" href="/assets/history.html.3bb211d2.js"><link rel="prefetch" href="/assets/http-api.html.6b02a439.js"><link rel="prefetch" href="/assets/idea-plugin.html.811711b6.js"><link rel="prefetch" href="/assets/install-detail.html.62e31be3.js"><link rel="prefetch" href="/assets/jad.html.c455880c.js"><link rel="prefetch" href="/assets/jfr.html.be02b7aa.js"><link rel="prefetch" href="/assets/jvm.html.0d9fa640.js"><link rel="prefetch" href="/assets/keymap.html.c10f2c0a.js"><link rel="prefetch" href="/assets/logger.html.e81218cb.js"><link rel="prefetch" href="/assets/manual-install.html.5df892be.js"><link rel="prefetch" href="/assets/mbean.html.62dfd65b.js"><link rel="prefetch" href="/assets/mc.html.c12a8cd0.js"><link rel="prefetch" href="/assets/memory.html.bad89d78.js"><link rel="prefetch" href="/assets/monitor.html.42a25d25.js"><link rel="prefetch" href="/assets/ognl.html.ba1865ec.js"><link rel="prefetch" href="/assets/options.html.2112e87d.js"><link rel="prefetch" href="/assets/perfcounter.html.f0528cf8.js"><link rel="prefetch" href="/assets/profiler.html.a899b52f.js"><link rel="prefetch" href="/assets/pwd.html.7004966b.js"><link rel="prefetch" href="/assets/quick-start.html.89d9fffc.js"><link rel="prefetch" href="/assets/quit.html.4aad9904.js"><link rel="prefetch" href="/assets/redefine.html.aa3e7277.js"><link rel="prefetch" href="/assets/release-notes.html.84b2ae52.js"><link rel="prefetch" href="/assets/reset.html.5e5dbf72.js"><link rel="prefetch" href="/assets/retransform.html.6c7bac51.js"><link rel="prefetch" href="/assets/save-log.html.b12e2779.js"><link rel="prefetch" href="/assets/sc.html.d47077da.js"><link rel="prefetch" href="/assets/session.html.d3100a10.js"><link rel="prefetch" href="/assets/sm.html.7fe6e105.js"><link rel="prefetch" href="/assets/spring-boot-starter.html.60806736.js"><link rel="prefetch" href="/assets/stack.html.49e14def.js"><link rel="prefetch" href="/assets/start-arthas.html.127785cf.js"><link rel="prefetch" href="/assets/stop.html.6ce326a3.js"><link rel="prefetch" href="/assets/sysenv.html.86745ab9.js"><link rel="prefetch" href="/assets/syspr
2 years ago
<link rel="stylesheet" href="/assets/style.cf0d4c26.css">
</head>
<body>
5 months ago
<div id="app"><!--[--><div class="theme-container"><!--[--><header class="navbar"><div class="toggle-sidebar-button" title="toggle sidebar" aria-expanded="false" role="button" tabindex="0"><div class="icon" aria-hidden="true"><span></span><span></span><span></span></div></div><span><a href="/en/" class="" data-v-a8869d06><!----><span class="site-name can-hide" data-v-a8869d06>arthas</span><span class="navbar-version" data-v-a8869d06>v4.0.2</span></a></span><div class="navbar-items-wrapper" style=""><!--[--><!--]--><nav class="navbar-items can-hide"><!--[--><div class="navbar-item"><a href="/en/" class="" aria-label="HOME"><!--[--><!--]--> HOME <!--[--><!--]--></a></div><div class="navbar-item"><a class="external-link" href="/doc/arthas-tutorials.html?language=en&amp;id=arthas-basics" rel="noopener noreferrer" target="_blank" aria-label="ONLINE TUTORIALS"><!--[--><!--]--><span>ONLINE TUTORIALS</span><span><svg class="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"><path fill="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><polygon fill="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><span class="external-link-icon-sr-only">open in new window</span></span><!--[--><!--]--></a></div><div class="navbar-item"><a href="/en/doc" class="router-link-active" aria-label="DOCS"><!--[--><!--]--> DOCS <!--[--><!--]--></a></div><div class="navbar-item"><a href="/en/doc/commands.md" class="" aria-label="COMMANDS"><!--[--><!--]--> COMMANDS <!--[--><!--]--></a></div><div class="navbar-item"><a href="/en/doc/download.md" class="" aria-label="DOWNLOAD"><!--[--><!--]--> DOWNLOAD <!--[--><!--]--></a></div><div class="navbar-item"><div class="navbar-dropdown-wrapper"><button class="navbar-dropdown-title" type="button" aria-label="VERSIONS"><span class="title">VERSIONS</span><span class="arrow down"></span></button><button class="navbar-dropdown-title-mobile" type="button" aria-label="VERSIONS"><span class="title">VERSIONS</span><span class="right arrow"></span></button><ul style="display:none;" class="navbar-dropdown"><!--[--><li class="navbar-dropdown-item"><a class="external-link" href="https://arthas.aliyun.com/3.x/en/" rel="noopener noreferrer" target="_blank" aria-label="v3.x"><!--[--><!--]--><span>v3.x</span><span><svg class="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"><path fill="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><polygon fill="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><span class="external-link-icon-sr-only">open in new window</span></span><!--[--><!--]--></a></li><!--]--></ul></div></div><div class="navbar-item"><div class="navbar-dropdown-wrapper"><button class="navbar-dropdown-title" type="button" aria-label="Select language"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1em" height="1em" style="height:1.25rem;width:1.25rem;vertical-align:bottom;" viewbox="0 0 24 24"><path fill="currentColor" d="M13.35 22q-.6 0-.862-.387q-.263-.388-.063-.963l3.65-9.675q.15-.4.563-.688Q17.05 10 17.5 10q.425 0 .85.287q.425.288.575.688l3.65 9.675q.2.575-.062.963q-.263.387-.888.387q-.275 0-.5-.175q-.225-.175-.325-.425l-.85-2.45H15.1l-.875 2.45q-.1.25-.35.425q-.25.175-.525.175Zm2.35-4.8h3.6l-1.75-4.95h-.1ZM7.15 8.55q.4.725.85 1.337q.45.613 1.05 1.263q1.1-1.2 1.825-2.462Q11.6 7.425 12.1 6H2q-.425 0-.712-.287Q1 5.425 1 5t.288-.713Q1.575 4 2 4h6V3q0-.425.288-.713Q8.575 2 9 2t.713.287Q10 2.575 10 3v1h6q.425 0 .712.287Q17 4.575 17 5t-.288.713Q16.425 6 16 6h-1.9q-.525 1.775-1.425 3.45q-.9 1.675-2.225 3.15l2.4 2.45l-.75 2.05L9 14l-4.3 4.3q
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>. Other valid profiling modes can be specified with the <code>--event</code> parameter, see relevant contents below.</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-profiling-status" tabindex="-1"><a class="header-anchor" href="#view-profiling-status" aria-hidden="true">#</a> View profiling 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="view-profiler-memory-usage" tabindex="-1"><a class="header-anchor" href="#view-profiler-memory-usage" aria-hidden="true">#</a> View profiler memory usage</h2><div class="language-text ext-text line-numbers-mode"><pre class="language-text"><code>$ profiler meminfo
Call trace storage: 10244 KB
Dictionaries: 72 KB
Code cache: 12890 KB
------------------------------
Total: 23206 KB
</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></div><h2 id="stop-profiler" tabindex="-1"><a class="header-anchor" href="#stop-profiler" aria-hidden="true">#</a> Stop profiler</h2><h3 id="generating-flame-graph-results" tabindex="-1"><a class="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 <a href="https://github.com/BrendanGregg/FlameGraph" target="_blank" rel="noopener noreferrer">Flame Graph<span><svg class="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"><path fill="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><polygon fill="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><span class="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><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ profiler stop <span class="token parameter variable">--format</span> flamegraph
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>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><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><p>By default, arthas uses port 3658, which can be opened: <a href="http://localhost:3658/arthas-output/" target="_blank" rel="noopener noreferrer">http://localhost:3658/arthas-output/<span><svg class="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"><path fill="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><polygon fill="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><span class="external-link-icon-sr-only">open in new window</span></span></a> View the <code>arthas-output</code> directory below Profiler results:</p><p><img src="/images/arthas-output.jpg" alt=""></p><p>Click to view specific results:</p><p><img src="/images/arthas-output-svg.jpg" 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
5 months ago
ctimer
</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></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
5 months ago
ctimer
Java method calls:
ClassName.methodName
Perf events:
page-faults
context-switches
cycles
instructions
cache-references
cache-misses
branch-instructions
branch-misses
bus-cycles
L1-dcache-load-misses
LLC-load-misses
dTLB-load-misses
rNNN
pmu/event-descriptor/
mem:breakpoint
trace:tracepoint
kprobe:func
uprobe:path
5 months ago
</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 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>If you encounter the permissions/configuration issues of the OS itself and then missing some events, you can refer to the <a href="https://github.com/jvm-profiling-tools/async-profiler" target="_blank" rel="noopener noreferrer">async-profiler<span><svg class="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"><path fill="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><polygon fill="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><span class="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><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ profiler start <span class="token parameter variable">--event</span> alloc
3 years ago
</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> 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><h2 id="dump-action" tabindex="-1"><a class="header-anchor" href="#dump-action" aria-hidden="true">#</a> Dump action</h2><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ profiler dump
OK
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="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><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">&#39;start,framebuf=5000000&#39;</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">&#39;stop,file=/tmp/result.html&#39;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>Specific format reference: <a href="https://github.com/async-profiler/async-profiler/blob/v2.9/src/arguments.cpp#L52" target="_blank" rel="noopener noreferrer">arguments.cpp<span><svg class="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"><path fill="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><polygon fill="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><span class="external-link-icon-sr-only">open in new window</span></span></a></p><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, version, execute, meminfo, stop, load, dumpFlat, dump, actions, dumpTraces, status, check<span class="token punctuation">]</span>
3 years ago
</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">2.9</span> built on May <span class="token number">8</span> <span class="token number">2023</span>
Copyright <span class="token number">2016</span>-2021 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-java-stack-depth" tabindex="-1"><a class="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&#39;t want to see stacks that are too deep. Below is usage example:</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler start <span class="token parameter variable">-j</span> <span class="token number">256</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h2 id="profiling-different-threads-separately" tabindex="-1"><a class="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><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler start <span class="token parameter variable">-t</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 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><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler stop --include<span class="token string">&#39;java/*&#39;</span> <span class="token parameter variable">--include</span> <span class="token string">&#39;com/demo/*&#39;</span> --exclude<span class="token string">&#39;*Unsafe.park*&#39;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="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><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 in collect action:</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler collect <span class="token parameter variable">--duration</span> <span class="token number">300</span>
3 years ago
</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
profiler start -o jfr
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><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="control-details-in-result" tabindex="-1"><a class="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 <a href="https://github.com/async-profiler/async-profiler#readme" target="_blank" rel="noopener noreferrer">async-profiler README<span><svg class="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"><path fill="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><polygon fill="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><span class="external-link-icon-sr-only">open in new window</span></span></a> and <a href="https://github.com/async-profiler/async-profiler/discussions" target="_blank" rel="noopener noreferrer">async-profiler Github Discussions<span><svg class="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"><path fill="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><polygon fill="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><span class="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><div class="language-text ext-text line-numbers-mode"><pre class="language-text"><code>profiler stop -s -g -a -l --title &lt;flametitle&gt; --minwidth 15 --reverse
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h2 id="the-unknown-in-profiler-result" tabindex="-1"><a class="header-anchor" href="#the-unknown-in-profiler-result" aria-hidden="true">#</a> The &#39;unknown&#39; in profiler result</h2><ul><li>https://github.com/jvm-profiling-tools/async-profiler/discussions/409</li></ul><h2 id="config-locks-allocations-profiling-threshold" tabindex="-1"><a class="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><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler start <span class="token parameter variable">-e</span> lock <span class="token parameter variable">--lock</span> 10ms
profiler start <span class="token parameter variable">-e</span> alloc <span class="token parameter variable">--alloc</span> 2m
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="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><h2 id="config-jfr-chunks" tabindex="-1"><a class="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><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler start <span class="token parameter variable">-f</span> profile.jfr <span class="token parameter variable">--chunksize</span> 100m <span class="token parameter variable">--chunktime</span> 1h
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h2 id="group-threads-by-scheduling-policy" tabindex="-1"><a class="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><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler start <span class="token parameter variable">--sched</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>The second line from bottom in flamegraph represent the scheduling policy.</p><h2 id="build-allocation-profile-from-live-objects-only" tabindex="-1"><a class="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><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler start <span class="token parameter variable">--live</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h2 id="config-method-of-collecting-c-stack-frames" tabindex="-1"><a class="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><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler <span class="token parameter variable">--cstack</span> fp
5 months ago
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>The command above will collection Frame Pointer of C stacks.</p><h2 id="start-stop-profiling-when-a-specified-native-function-is-executed" tabindex="-1"><a class="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><h3 id="time-to-safepoint-profiling" tabindex="-1"><a class="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><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler start <span class="token parameter variable">--begin</span> SafepointSynchronize::begin <span class="token parameter variable">--end</span> RuntimeService::record_safepoint_synchronized
profiler start <span class="token parameter variable">--ttsp</span> <span class="token parameter variable">--format</span> jfr
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="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><h2 id="generate-jfr-file-using-events-recorded-by-profiler" tabindex="-1"><a class="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><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler start <span class="token parameter variable">-e</span> cpu <span class="token parameter variable">--jfrsync</span> profile <span class="token parameter variable">-f</span> combined.jfr
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>Directly specify a list of JFR events, for example, to enable jdk.YoungGarbageCollection and jdk.OldGarbageCollection events:</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler start <span class="token parameter variable">-e</span> cpu <span class="token parameter variable">--jfrsync</span> +jdk.YoungGarbageCollection+jdk.OldGarbageCollection <span class="token parameter variable">-f</span> combined.jfr
</code></pre><div class="line-numbers" aria-hidden="true"><div class="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><h2 id="run-profiler-in-a-loop" tabindex="-1"><a class="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><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler start <span class="token parameter variable">--loop</span> 1h <span class="token parameter variable">-f</span> /var/log/profile-%t.jfr
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h2 id="timeout-option" tabindex="-1"><a class="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 <a href="https://github.com/async-profiler/async-profiler/discussions/789" target="_blank" rel="noopener noreferrer">async-profiler Github Discussions<span><svg class="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"><path fill="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><polygon fill="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><span class="external-link-icon-sr-only">open in new window</span></span></a>.</p><h2 id="wall-option" tabindex="-1"><a class="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><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler start <span class="token parameter variable">-e</span> cpu <span class="token parameter variable">-i</span> <span class="token number">10</span> <span class="token parameter variable">--wall</span> <span class="token number">100</span> <span class="token parameter variable">-f</span> out.jfr
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h2 id="ctimer-events" tabindex="-1"><a class="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 <a href="https://github.com/async-profiler/async-profiler/issues/855" target="_blank" rel="noopener noreferrer">async-profiler Github Issues<span><svg class="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"><path fill="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><polygon fill="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><span class="external-link-icon-sr-only">open in new window</span></span></a> for more information.</p><p>Example:</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler start <span class="token parameter variable">-e</span> ctimer <span class="token parameter variable">-o</span> jfr <span class="token parameter variable">-f</span> ./out-test.jfr
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h2 id="vtable-feature" tabindex="-1"><a class="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 <a href="https://github.com/async-profiler/async-profiler/issues/736" target="_blank" rel="noopener noreferrer">async-profiler Github Issues<span><svg class="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"><path fill="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><polygon fill="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><span class="external-link-icon-sr-only">open in new window</span></span></a> for more information.</p><p>Example:</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler start <span class="token parameter variable">-F</span> vtable
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h2 id="comptask-feature" tabindex="-1"><a class="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 <a href="https://github.com/async-profiler/async-profiler/issues/777" target="_blank" rel="noopener noreferrer">async-profiler Github Issues<span><svg class="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"><path fill="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><polygon fill="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><span class="external-link-icon-sr-only">open in new window</span></span></a> for more information.</p><p>Example:</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler start <span class="token parameter variable">-F</span> comptask
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h2 id="configuring-alternative-profiling-signals" tabindex="-1"><a class="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 <a href="https://github.com/async-profiler/async-profiler/issues/759" target="_blank" rel="noopener noreferrer">async-profiler Github Issues<span><svg class="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"><path fill="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><polygon fill="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><span class="external-link-icon-sr-only">open in new window</span></span></a> for more information.</p><p>Syntax</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler start <span class="token parameter variable">--signal</span> <span class="token operator">&lt;</span>signal number<span class="token operator">&gt;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="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><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler start <span class="token parameter variable">--signal</span> <span class="token operator">&lt;</span>CPU signal number<span class="token operator">&gt;</span>/<span class="token operator">&lt;</span>Wall signal number<span class="token operator">&gt;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h2 id="clock-option" tabindex="-1"><a class="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><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler start <span class="token parameter variable">--clock</span> <span class="token operator">&lt;</span>tsc<span class="token operator">|</span>monotonic<span class="token operator">&gt;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>Parameters</p><ul><li><p><code>tsc</code>: Use the CPU&#39;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&#39;s monotonic clock (<code>CLOCK_MONOTONIC</code>). This helps align timestamps between multiple data sources. See <a href="https://github.com/async-profiler/async-profiler/issues/723" target="_blank" rel="noopener noreferrer">async-profiler Github Issues<span><svg class="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"><path fill="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><polygon fill="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><span class="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><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler start <span class="token parameter variable">--clock</span> monotonic
</code></pre><div class="line-numbers" aria-hidden="true"><div class="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><h2 id="norm-option" tabindex="-1"><a class="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 <a href="https://github.com/async-profiler/async-profiler/issues/832" target="_blank" rel="noopener noreferrer">async-profiler Github Issues<span><svg class="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"><path fill="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><polygon fill="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><span class="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><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>profiler start <span class="token parameter variable">--norm</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div></div><!--[--><!--]--></div><footer class="page-meta right-menu-padding" data-v-fdd717e0><div class="meta-item edit-link"><a class="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><svg class="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"><path fill="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><polygon fill="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><span class="external-link-icon-sr-only">open in new window</span></span><!--[--><!--]--></a></div><div class="meta-item last-updated"><span class="meta-item-label">Last Updated: </span><!----></div><div class="meta-item contributors"><span class="meta-item-label">Contributors: </span><span class="meta-item-info"><!--[--><!--[--><span class="contributor" title="email: wenchenghuang@mail.bnu.edu.cn">Winson Huang</span><!--[-->, <!--]--><!--]--><!--[--><span class="contributor" title="email: hengyunabc@gmail.com">hengyunabc</span><!--[-->, <!--]--><!--]--><!--[--><span class="contributor" title="email: 18235787078@163.com">CrazyCoder</span><!--[-->, <!--]--><!--]--><!--[--><span class="contributor" title="email: 68638598+Allan-QLB@users.noreply.github.com">Allan-QLB</span><!--[-->, <!--]--><!--]--><!--[--><span class="contributor" title="email: i@fatpandac.com">Fatpandac</span><!--[-->, <!--]--><!--]--><!--[--><span class="contributor" title="email: hengyunabc@users.noreply.github.com">hengyunabc</span><!--[-->, <!--]--><!--]--><!--[--><span class="contributor" title="email: 983433479@qq.com">汪吉</span><!--[-->, <!--]--><!--]--><!--[--><span class="contributor" title="email: hollowman186@vip.qq.com">Hollow Man</span><!----><!--]--><!--]--></span></div></footer><nav class="page-nav right-menu-padding" data-v-fdd717e0><p class="inner"><span class="prev"><a href="/en/doc/perfcounter.html" class="" aria-label="perfcounter"><!--[--><!--]--> perfcounter <!--[--><!--]--></a></span><span class="next"><a href="/en/doc/pwd.html" class="" aria-label="pwd"><!--[--><!--]--> pwd <!--[--><!--]--></a></span></p></nav><!--[--><!--]--></main><!--]--></div><!----><!--]--></div>
<script type="module" src="/assets/app.e05b0501.js" defer></script>
</body>
</html>