update doc

This commit is contained in:
hengyunabc
2021-02-08 16:35:22 +08:00
parent 89afe2d24f
commit b9cdad5138
10 changed files with 167 additions and 4 deletions
+4
View File
@@ -70,3 +70,7 @@ watch demo.MathGame <init> '{params,returnObj,throwExp}' -v -n 5 -x 3 '1==1'
比如: 使用 skywalking V8.1.0 以下版本 [无法trace、watch 被skywalking agent 增强过的类](https://github.com/alibaba/arthas/issues/1141), V8.1.0 以上版本可以兼容使用,更多参考skywalking配置 [skywalking compatible with other javaagent bytecode processing](https://github.com/apache/skywalking/blob/v8.1.0/docs/en/FAQ/Compatible-with-other-javaagent-bytecode-processing.md)。
##### Arthas能不能离线使用
可以。下载全量包解压即可,参考: [download.md]。
+38
View File
@@ -204,3 +204,41 @@ Affect(class count: 1 , method count: 1) cost in 34 ms, listenerId: 1
```
通过指定`listenerId`的方式动态trace,可以不断深入。另外 `watch`/`tt`/`monitor`等命令也支持类似的功能。
### trace结果时间不准确问题
比如下面的结果里:`0.705196 > (0.152743 + 0.145825)`
```bash
$ trace demo.MathGame run -n 1
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 66 ms, listenerId: 1
`---ts=2021-02-08 11:27:36;thread_name=main;id=1;is_daemon=false;priority=5;TCCL=sun.misc.Launcher$AppClassLoader@232204a1
`---[0.705196ms] demo.MathGame:run()
+---[0.152743ms] demo.MathGame:primeFactors() #24
`---[0.145825ms] demo.MathGame:print() #25
```
那么其它的时间消耗在哪些地方?
1. 没有被trace到的函数。比如`java.*` 下的函数调用默认会忽略掉。通过增加`--skipJDKMethod false`参数可以打印出来。
```bash
$ trace demo.MathGame run --skipJDKMethod false
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 35 ms, listenerId: 2
`---ts=2021-02-08 11:27:48;thread_name=main;id=1;is_daemon=false;priority=5;TCCL=sun.misc.Launcher$AppClassLoader@232204a1
`---[0.810591ms] demo.MathGame:run()
+---[0.034568ms] java.util.Random:nextInt() #23
+---[0.119367ms] demo.MathGame:primeFactors() #24 [throws Exception]
+---[0.017407ms] java.lang.StringBuilder:<init>() #28
+---[0.127922ms] java.lang.String:format() #57
+---[min=0.01419ms,max=0.020221ms,total=0.034411ms,count=2] java.lang.StringBuilder:append() #57
+---[0.021911ms] java.lang.Exception:getMessage() #57
+---[0.015643ms] java.lang.StringBuilder:toString() #57
`---[0.086622ms] java.io.PrintStream:println() #57
```
2. 非函数调用的指令消耗。比如 `i++`, `getfield`等指令。
3. 在代码执行过程中,JVM可能出现停顿,比如GC,进入同步块等。
+6 -1
View File
@@ -69,4 +69,9 @@ watch demo.MathGame <init> '{params,returnObj,throwExp}' -v -n 5 -x 3 '1==1'
When error log appear `java.lang.ClassFormatError: null`, it is usually modified by other bytecode tools that are not compatible with arthas modified bytecode.
For example: use skywalking V8.1.0 below [cannot trace, watch classes enhanced by skywalking agent](https://github.com/alibaba/arthas/issues/1141), V8.1.0 or above is compatible, refer to skywalking configuration for more details. [skywalking compatible with other javaagent bytecode processing](https://github.com/apache/skywalking/blob/v8.1.0/docs/en/FAQ/Compatible-with-other-javaagent-bytecode-processing.md).
For example: use skywalking V8.1.0 below [cannot trace, watch classes enhanced by skywalking agent](https://github.com/alibaba/arthas/issues/1141), V8.1.0 or above is compatible, refer to skywalking configuration for more details. [skywalking compatible with other javaagent bytecode processing](https://github.com/apache/skywalking/blob/v8.1.0/docs/en/FAQ/Compatible-with-other-javaagent-bytecode-processing.md).
##### Can I use arthas offline?
Yes. Just download the full size package and unzip it, refer to: [download.md].
+39 -1
View File
@@ -199,4 +199,42 @@ At terminal 1, you can see that the trace result has increased by one layer:
`---[0.084025ms] demo.MathGame:print() #25
```
Dynamic trace by specifying `listenerId`, you can go deeper and deeper. In addition, commands such as `watch`/`tt`/`monitor` also support similar functionality.
Dynamic trace by specifying `listenerId`, you can go deeper and deeper. In addition, commands such as `watch`/`tt`/`monitor` also support similar functionality.
### Trace result time inaccuracy problem
For example, in the following result: `0.705196 > (0.152743 + 0.145825)`
```bash
$ trace demo.MathGame run -n 1
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 66 ms, listenerId: 1
`---ts=2021-02-08 11:27:36;thread_name=main;id=1;is_daemon=false;priority=5;TCCL=sun.misc.Launcher$AppClassLoader@232204a1
`--[0.705196ms] demo.MathGame:run()
+---[0.152743ms] demo.MathGame:primeFactors() #24
`--[0.145825ms] demo.MathGame:print() #25
```
So where is the rest of the time consumed?
1. Methods that are not traced to. For example, methods under `java.*` are ignored by default. This can be printed out by adding the `-skipJDKMethod false` parameter.
```bash
$ trace demo.MathGame run --skipJDKMethod false
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 35 ms, listenerId: 2
`---ts=2021-02-08 11:27:48;thread_name=main;id=1;is_daemon=false;priority=5;TCCL=sun.misc.Launcher$AppClassLoader@232204a1
`--[0.810591ms] demo.MathGame:run()
+--[0.034568ms] java.util.Random:nextInt() #23
+---[0.119367ms] demo.MathGame:timeFactors() #24 [throws Exception]
+---[0.017407ms] java.lang.StringBuilder:<init>() #28
+--[0.127922ms] java.lang.String:format() #57
+---[min=0.01419ms,max=0.020221ms,total=0.034411ms,count=2] java.lang.StringBuilder:append() #57
+--[0.021911ms] java.lang.Exception:getMessage() #57
+---[0.015643ms] java.lang.StringBuilder:toString() #57
`--[0.086622ms] java.io.PrintStream:println() #57
```
2. Instruction consumption. For example, instructions such as `i++`, `getfield`, etc.
3. Possible JVM pause during code execution, such as GC, entering synchronization blocks, etc.
+5
View File
@@ -122,6 +122,7 @@
<li class="toctree-l2"><a class="reference internal" href="#how-to-filter-method-with-the-same-name">How to filter method with the same name?</a></li>
<li class="toctree-l2"><a class="reference internal" href="#how-to-watch-or-trace-constructor">How to watch or trace constructor?</a></li>
<li class="toctree-l2"><a class="reference internal" href="#java-lang-classformaterror-null-skywalking-arthas-compatible-use">java.lang.ClassFormatError: null, skywalking arthas compatible use</a></li>
<li class="toctree-l2"><a class="reference internal" href="#can-i-use-arthas-offline">Can I use arthas offline?</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference external" href="https://github.com/alibaba/arthas">Star me at GitHub</a></li>
@@ -251,6 +252,10 @@
<p>When error log appear <code class="docutils literal notranslate"><span class="pre">java.lang.ClassFormatError:</span> <span class="pre">null</span></code>, it is usually modified by other bytecode tools that are not compatible with arthas modified bytecode.</p>
<p>For example: use skywalking V8.1.0 below <a class="reference external" href="https://github.com/alibaba/arthas/issues/1141">cannot trace, watch classes enhanced by skywalking agent</a>, V8.1.0 or above is compatible, refer to skywalking configuration for more details. <a class="reference external" href="https://github.com/apache/skywalking/blob/v8.1.0/docs/en/FAQ/Compatible-with-other-javaagent-bytecode-processing">skywalking compatible with other javaagent bytecode processing</a>.</p>
</div>
<div class="section" id="can-i-use-arthas-offline">
<h2>Can I use arthas offline?<a class="headerlink" href="#can-i-use-arthas-offline" title="Permalink to this headline"></a></h2>
<p>Yes. Just download the full size package and unzip it, refer to: [download.md].</p>
</div>
</div>
+1 -1
View File
File diff suppressed because one or more lines are too long
+34
View File
@@ -141,6 +141,7 @@
<li class="toctree-l4"><a class="reference internal" href="#dynamic-trace">Dynamic trace</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#trace-result-time-inaccuracy-problem">Trace result time inaccuracy problem</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="stack.html">stack</a></li>
@@ -445,6 +446,39 @@ Affect(class count: 1 , method count: 1) cost in 34 ms, listenerId: 1</pre></div
<p>Dynamic trace by specifying <code class="docutils literal notranslate"><span class="pre">listenerId</span></code>, you can go deeper and deeper. In addition, commands such as <code class="docutils literal notranslate"><span class="pre">watch</span></code>/<code class="docutils literal notranslate"><span class="pre">tt</span></code>/<code class="docutils literal notranslate"><span class="pre">monitor</span></code> also support similar functionality.</p>
</div>
</div>
<div class="section" id="trace-result-time-inaccuracy-problem">
<h2>Trace result time inaccuracy problem<a class="headerlink" href="#trace-result-time-inaccuracy-problem" title="Permalink to this headline"></a></h2>
<p>For example, in the following result: <code class="docutils literal notranslate"><span class="pre">0.705196</span> <span class="pre">&gt;</span> <span class="pre">(0.152743</span> <span class="pre">+</span> <span class="pre">0.145825)</span></code></p>
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">$ trace demo.MathGame run -n 1
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 66 ms, listenerId: 1
`---ts=2021-02-08 11:27:36;thread_name=main;id=1;is_daemon=false;priority=5;TCCL=sun.misc.Launcher$AppClassLoader@232204a1
`--[0.705196ms] demo.MathGame:run()
+---[0.152743ms] demo.MathGame:primeFactors() #24
`--[0.145825ms] demo.MathGame:print() #25</pre></div>
</div>
<p>So where is the rest of the time consumed?</p>
<ol>
<li><p>Methods that are not traced to. For example, methods under <code class="docutils literal notranslate"><span class="pre">java.*</span></code> are ignored by default. This can be printed out by adding the <code class="docutils literal notranslate"><span class="pre">-skipJDKMethod</span> <span class="pre">false</span></code> parameter.</p>
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">$ trace demo.MathGame run --skipJDKMethod false
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 35 ms, listenerId: 2
`---ts=2021-02-08 11:27:48;thread_name=main;id=1;is_daemon=false;priority=5;TCCL=sun.misc.Launcher$AppClassLoader@232204a1
`--[0.810591ms] demo.MathGame:run()
+--[0.034568ms] java.util.Random:nextInt() #23
+---[0.119367ms] demo.MathGame:timeFactors() #24 [throws Exception]
+---[0.017407ms] java.lang.StringBuilder:&lt;init&gt;() #28
+--[0.127922ms] java.lang.String:format() #57
+---[min=0.01419ms,max=0.020221ms,total=0.034411ms,count=2] java.lang.StringBuilder:append() #57
+--[0.021911ms] java.lang.Exception:getMessage() #57
+---[0.015643ms] java.lang.StringBuilder:toString() #57
`--[0.086622ms] java.io.PrintStream:println() #57</pre></div>
</div>
</li>
<li><p>Instruction consumption. For example, instructions such as <code class="docutils literal notranslate"><span class="pre">i++</span></code>, <code class="docutils literal notranslate"><span class="pre">getfield</span></code>, etc.</p></li>
<li><p>Possible JVM pause during code execution, such as GC, entering synchronization blocks, etc.</p></li>
</ol>
</div>
</div>
+5
View File
@@ -127,6 +127,7 @@
<li class="toctree-l2"><a class="reference internal" href="#id2">方法同名过滤</a></li>
<li class="toctree-l2"><a class="reference internal" href="#watchtrace">怎么watch、trace 构造函数 ?</a></li>
<li class="toctree-l2"><a class="reference internal" href="#java-lang-classformaterror-nullskywalking-arthas">java.lang.ClassFormatError: null、skywalking arthas 兼容使用</a></li>
<li class="toctree-l2"><a class="reference internal" href="#arthas">Arthas能不能离线使用</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference external" href="https://github.com/alibaba/arthas">Star me at GitHub</a></li>
@@ -256,6 +257,10 @@
<p>当出现这个错误日志<code class="docutils literal notranslate"><span class="pre">java.lang.ClassFormatError:</span> <span class="pre">null</span></code>,通常情况下都是被其他字节码工具修改过与arthas修改字节码不兼容。</p>
<p>比如: 使用 skywalking V8.1.0 以下版本 <a class="reference external" href="https://github.com/alibaba/arthas/issues/1141">无法trace、watch 被skywalking agent 增强过的类</a>, V8.1.0 以上版本可以兼容使用,更多参考skywalking配置 <a class="reference external" href="https://github.com/apache/skywalking/blob/v8.1.0/docs/en/FAQ/Compatible-with-other-javaagent-bytecode-processing">skywalking compatible with other javaagent bytecode processing</a>。</p>
</div>
<div class="section" id="arthas">
<h2>Arthas能不能离线使用<a class="headerlink" href="#arthas" title="永久链接至标题"></a></h2>
<p>可以。下载全量包解压即可,参考: [download.md]。</p>
</div>
</div>
+1 -1
View File
File diff suppressed because one or more lines are too long
+34
View File
@@ -146,6 +146,7 @@
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#id9">动态trace</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id10">trace结果时间不准确问题</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="stack.html">stack</a></li>
@@ -450,6 +451,39 @@ Affect(class count: 1 , method count: 1) cost in 34 ms, listenerId: 1</pre></div
</div>
<p>通过指定<code class="docutils literal notranslate"><span class="pre">listenerId</span></code>的方式动态trace,可以不断深入。另外 <code class="docutils literal notranslate"><span class="pre">watch</span></code>/<code class="docutils literal notranslate"><span class="pre">tt</span></code>/<code class="docutils literal notranslate"><span class="pre">monitor</span></code>等命令也支持类似的功能。</p>
</div>
<div class="section" id="id10">
<h2>trace结果时间不准确问题<a class="headerlink" href="#id10" title="永久链接至标题"></a></h2>
<p>比如下面的结果里:<code class="docutils literal notranslate"><span class="pre">0.705196</span> <span class="pre">&gt;</span> <span class="pre">(0.152743</span> <span class="pre">+</span>&#160; <span class="pre">0.145825)</span></code></p>
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">$ trace demo.MathGame run -n 1
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 66 ms, listenerId: 1
`---ts=2021-02-08 11:27:36;thread_name=main;id=1;is_daemon=false;priority=5;TCCL=sun.misc.Launcher$AppClassLoader@232204a1
`---[0.705196ms] demo.MathGame:run()
+---[0.152743ms] demo.MathGame:primeFactors() #24
`---[0.145825ms] demo.MathGame:print() #25</pre></div>
</div>
<p>那么其它的时间消耗在哪些地方?</p>
<ol>
<li><p>没有被trace到的函数。比如<code class="docutils literal notranslate"><span class="pre">java.*</span></code> 下的函数调用默认会忽略掉。通过增加<code class="docutils literal notranslate"><span class="pre">--skipJDKMethod</span> <span class="pre">false</span></code>参数可以打印出来。</p>
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">$ trace demo.MathGame run --skipJDKMethod false
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 35 ms, listenerId: 2
`---ts=2021-02-08 11:27:48;thread_name=main;id=1;is_daemon=false;priority=5;TCCL=sun.misc.Launcher$AppClassLoader@232204a1
`---[0.810591ms] demo.MathGame:run()
+---[0.034568ms] java.util.Random:nextInt() #23
+---[0.119367ms] demo.MathGame:primeFactors() #24 [throws Exception]
+---[0.017407ms] java.lang.StringBuilder:&lt;init&gt;() #28
+---[0.127922ms] java.lang.String:format() #57
+---[min=0.01419ms,max=0.020221ms,total=0.034411ms,count=2] java.lang.StringBuilder:append() #57
+---[0.021911ms] java.lang.Exception:getMessage() #57
+---[0.015643ms] java.lang.StringBuilder:toString() #57
`---[0.086622ms] java.io.PrintStream:println() #57</pre></div>
</div>
</li>
<li><p>非函数调用的指令消耗。比如 <code class="docutils literal notranslate"><span class="pre">i++</span></code>, <code class="docutils literal notranslate"><span class="pre">getfield</span></code>等指令。</p></li>
<li><p>在代码执行过程中,JVM可能出现停顿,比如GC,进入同步块等。</p></li>
</ol>
</div>
</div>