Skip to content

Commit

Permalink
Site updated: 2024-07-10 11:27:45
Browse files Browse the repository at this point in the history
  • Loading branch information
AnubisCL committed Jul 10, 2024
1 parent 93922ad commit 9b485a1
Show file tree
Hide file tree
Showing 84 changed files with 2,939 additions and 2,413 deletions.
120 changes: 119 additions & 1 deletion 2024/01/24/Arthas/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ <h1 class="description center-align post-title">Arthas</h1>

<div class="post-date info-break-policy">
<i class="far fa-calendar-check fa-fw"></i>更新日期:&nbsp;&nbsp;
2024-06-26
2024-07-10
</div>


Expand Down Expand Up @@ -487,6 +487,124 @@ <h2 id="4-vmoption"><a href="#4-vmoption" class="headerlink" title="4.vmoption">
MaxHeapFreeRatio <span class="token number">100</span> DEFAULT <span class="token boolean">true</span> <span class="token punctuation">[</span>控制堆内存的最大空闲比例<span class="token punctuation">]</span>
PrintConcurrentLocks <span class="token boolean">false</span> DEFAULT <span class="token boolean">true</span> <span class="token punctuation">[</span>在进行垃圾回收时,是否打印持有锁的线程信息,帮助诊断死锁问题<span class="token punctuation">]</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>



<h3 id="Arthas:"><a href="#Arthas:" class="headerlink" title="Arthas:"></a>Arthas:</h3><h4 id="监控:"><a href="#监控:" class="headerlink" title="监控:"></a>监控:</h4><pre class="line-numbers language-powershell" data-language="powershell"><code class="language-powershell"><span class="token comment"># 请注意,这些命令,都通过字节码增强技术来实现的,会在指定类的方法中插入一些切面来实现数据统计和观测,</span>
<span class="token comment"># 因此在线上、预发使用时,请尽量明确需要观测的类、方法以及条件,诊断结束要执行 stop 或将增强过的类执行 reset 命令。</span>
<span class="token comment"># 1、quit 退出当前 Arthas 客户端,其他 Arthas 客户端不受影响</span>
<span class="token comment"># 2、shutdown——关闭 Arthas 服务端,所有 Arthas 客户端全部退出</span>
<span class="token comment"># 3、stop——和shutdown命令一致</span>

monitor——方法执行监控

watch——方法执行数据观测

trace——方法内部调用路径,并输出方法路径上的每个节点上耗时

stack——输出当前方法被调用的调用路径

tt——方法执行数据的时空隧道,记录下指定方法每次调用的入参和返回信息,并能对这些不同的时间下调用进行观测<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h4 id="watch"><a href="#watch" class="headerlink" title="watch:"></a>watch:</h4><pre class="line-numbers language-powershell" data-language="powershell"><code class="language-powershell">让你能方便的观察到指定方法的调用情况。
能观察到的范围为:返回值、抛出异常、入参,通过编写 OGNL 表达式进行对应变量的查看。

参数说明:
<span class="token keyword">class</span><span class="token operator">-</span>pattern 类名表达式匹配
method-pattern 方法名表达式匹配
express 观察表达式
condition-express 条件表达式
<span class="token operator">-</span>b 在方法调用之前观察
<span class="token operator">-</span>e 在方法异常之后观察
<span class="token operator">-</span>s 在方法返回之后观察
<span class="token operator">-</span>f 在方法结束之后<span class="token punctuation">(</span>正常返回和异常返回<span class="token punctuation">)</span>观察 默认开启
<span class="token operator">-</span>E 开启正则表达式匹配,默认为通配符匹配
<span class="token operator">-</span>x 指定输出结果的属性遍历深度,默认为 1
<span class="token operator">-</span>n 执行的次数

特别说明:
watch 命令定义了4个观察事件点,
<span class="token operator">-</span>b 方法调用前,<span class="token operator">-</span>e 方法异常后,<span class="token operator">-</span>s 方法返回后,<span class="token operator">-</span>f 方法结束后

4个观察事件点 <span class="token operator">-</span>b、<span class="token operator">-</span>e、<span class="token operator">-</span>s 默认关闭,<span class="token operator">-</span>f 默认打开,
当指定观察点被打开后,在相应事件点会对观察表达式进行求值并输出

这里要注意方法入参和方法出参的区别,有可能在中间被修改导致前后不一致,
除了 <span class="token operator">-</span>b 事件点 params 代表方法入参外,其余事件都代表方法出参

当使用 <span class="token operator">-</span>b 时,由于观察事件点是在方法调用前,此时返回值或异常均不存在

<span class="token operator">-</span>x 代表输出结果的深度 ,默认为 1

使用参考:
常规用法:
watch <span class="token keyword">class</span> method <span class="token punctuation">&#123;</span>params<span class="token punctuation">,</span>returnObj<span class="token punctuation">,</span>throwExp<span class="token punctuation">&#125;</span> <span class="token operator">-</span>x 1 <span class="token string">'#cost>200'</span>
观察表达式 <span class="token punctuation">&#123;</span> <span class="token punctuation">&#125;</span> 可以包裹结果集 <span class="token punctuation">,</span> 分割。输出的表达式变量定义
params 代表参数数组,returnObj 代表返回值,throwExp 代表抛出的异常。
过滤耗时大于200ms的

特殊用法:
1、调用第一个参数的方法或属性
watch <span class="token keyword">class</span> method <span class="token string">"&#123;params[0].length()&#125;"</span> <span class="token operator">-</span>x 1
如果是列表参数,则可以使用这种方式来获取列表中每个对象的指定属性
watch <span class="token keyword">class</span> method <span class="token string">"&#123;params[0].&#123; #this.length()&#125;&#125;"</span> <span class="token operator">-</span>x 1

2、按照条件过滤
如果是列表,则会过滤列表中长度大于7的字符串
watch <span class="token keyword">class</span> method <span class="token string">"&#123;params[0].&#123;? #this.length() > 7&#125;&#125;"</span> <span class="token operator">-</span>x 1
watch <span class="token keyword">class</span> method <span class="token string">"&#123;params,returnObj,throwExp&#125;"</span> <span class="token string">"params[0].length() > 7"</span> <span class="token operator">-</span>x 1
字符串长度 > 7 才会输出 params<span class="token punctuation">[</span>0<span class="token punctuation">]</span> 的值


3、过滤后统计
watch <span class="token keyword">class</span> method <span class="token string">"&#123;params[0].&#123;? #this.length() > 9&#125;.size()&#125;"</span> <span class="token operator">-</span>x 1
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h4 id="trace"><a href="#trace" class="headerlink" title="trace:"></a>trace:</h4><pre class="line-numbers language-powershell" data-language="powershell"><code class="language-powershell">trace 命令能主动搜索 <span class="token keyword">class</span><span class="token operator">-</span>pattern/method-pattern 对应的方法内部调用路径,
渲染和统计整个调用链路上的所有性能开销和追踪调用链路。

参数说明:
<span class="token keyword">class</span><span class="token operator">-</span>pattern 类名表达式匹配
method-pattern 方法名表达式匹配
condition-express 条件表达式
<span class="token operator">-</span>E 开启正则表达式匹配,默认为通配符匹配
<span class="token operator">-</span>n 命令执行次数
<span class="token comment">#cost 方法执行耗时</span>

使用参考:
常规用法:
trace <span class="token keyword">class</span> method <span class="token string">'#cost>100'</span> <span class="token operator">-</span>n 1
过滤大于100ms的调用链<span class="token punctuation">,</span>只输出一次

特殊用法:
trace命令只会trace匹配到的函数里的子调用,并不会向下trace多层。
因为trace是代价比较贵的,多层trace可能会导致最终要trace的类和函数非常多。

动态trace:
3<span class="token punctuation">.</span>3<span class="token punctuation">.</span>0 版本后支持。
打开终端1,trace run函数,可以看到打印出 listenerId: 1:

<span class="token namespace">[arthas@59161]</span>$ trace demo<span class="token punctuation">.</span>MathGame run
Press Q or Ctrl+C to abort<span class="token punctuation">.</span>
Affect<span class="token punctuation">(</span><span class="token keyword">class</span> count: 1 <span class="token punctuation">,</span> method count: 1<span class="token punctuation">)</span> cost in 112 ms<span class="token punctuation">,</span> listenerId: 1
`<span class="token operator">--</span><span class="token operator">-</span>ts=2020-07-09 16:48:11<span class="token punctuation">;</span>thread_name=main<span class="token punctuation">;</span>id=1<span class="token punctuation">;</span>is_daemon=false<span class="token punctuation">;</span>priority=5<span class="token punctuation">;</span>TCCL=sun<span class="token punctuation">.</span>misc<span class="token punctuation">.</span>Launcher<span class="token variable">$AppClassLoader</span>@3d4eac69
`<span class="token operator">--</span><span class="token operator">-</span><span class="token punctuation">[</span>1<span class="token punctuation">.</span>389634ms<span class="token punctuation">]</span> demo<span class="token punctuation">.</span>MathGame:run<span class="token punctuation">(</span><span class="token punctuation">)</span>
`<span class="token operator">--</span><span class="token operator">-</span><span class="token punctuation">[</span>0<span class="token punctuation">.</span>123934ms<span class="token punctuation">]</span> demo<span class="token punctuation">.</span>MathGame:primeFactors<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">#24 [throws Exception]</span>

现在想要深入子函数primeFactors,可以打开一个新终端2,
使用telnet localhost 3658连接上arthas,
再trace primeFactors时,指定listenerId。
再查看终端1,可以发现trace的结果增加了一层,打印了primeFactors函数里的内容

`<span class="token operator">--</span><span class="token operator">-</span>ts=2020-07-09 16:49:29<span class="token punctuation">;</span>thread_name=main<span class="token punctuation">;</span>id=1<span class="token punctuation">;</span>is_daemon=false<span class="token punctuation">;</span>priority=5<span class="token punctuation">;</span>TCCL=sun<span class="token punctuation">.</span>misc<span class="token punctuation">.</span>Launcher<span class="token variable">$AppClassLoader</span>@3d4eac69
`<span class="token operator">--</span><span class="token operator">-</span><span class="token punctuation">[</span>0<span class="token punctuation">.</span>492551ms<span class="token punctuation">]</span> demo<span class="token punctuation">.</span>MathGame:run<span class="token punctuation">(</span><span class="token punctuation">)</span>
`<span class="token operator">--</span><span class="token operator">-</span><span class="token punctuation">[</span>0<span class="token punctuation">.</span>113929ms<span class="token punctuation">]</span> demo<span class="token punctuation">.</span>MathGame:primeFactors<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">#24 [throws Exception]</span>
`<span class="token operator">--</span><span class="token operator">-</span><span class="token punctuation">[</span>0<span class="token punctuation">.</span>061462ms<span class="token punctuation">]</span> demo<span class="token punctuation">.</span>MathGame:primeFactors<span class="token punctuation">(</span><span class="token punctuation">)</span>
`<span class="token operator">--</span><span class="token operator">-</span><span class="token punctuation">[</span>0<span class="token punctuation">.</span>001018ms<span class="token punctuation">]</span> <span class="token keyword">throw</span>:java<span class="token punctuation">.</span>lang<span class="token punctuation">.</span>IllegalArgumentException<span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">#46</span>

通过指定listenerId的方式动态trace,可以不断深入。
另外 watch/tt/monitor等命令也支持类似的功能。
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>


</div>
<hr/>
Expand Down
16 changes: 8 additions & 8 deletions 2024/01/24/Docker/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1787,18 +1787,18 @@ <h2 id="7-SpringBoot微服务打包成镜像"><a href="#7-SpringBoot微服务打
<div class="article-badge left-badge text-color">
<i class="fas fa-chevron-left"></i>&nbsp;上一篇</div>
<div class="card">
<a href="/2024/01/24/%E9%9B%B6%E6%8B%B7%E8%B4%9D/">
<a href="/2024/01/24/Linux%20%E7%AC%94%E8%AE%B0/">
<div class="card-image">

<img src="/markdownimages/background/animation/15.jpg" class="responsive-img" alt="零拷贝">
<img src="/markdownimages/background/animation/17.jpg" class="responsive-img" alt="Linux 笔记">

<span class="card-title">零拷贝</span>
<span class="card-title">Linux 笔记</span>
</div>
</a>
<div class="card-content article-content">
<div class="summary block-with-text">

零拷贝
Linux 笔记整理

</div>
<div class="publish-info">
Expand All @@ -1809,8 +1809,8 @@ <h2 id="7-SpringBoot微服务打包成镜像"><a href="#7-SpringBoot微服务打

<i class="fas fa-bookmark fa-fw icon-category"></i>

<a href="/categories/%E9%9B%B6%E6%8B%B7%E8%B4%9D/" class="post-category">
零拷贝
<a href="/categories/Linux/" class="post-category">
Linux
</a>


Expand All @@ -1820,8 +1820,8 @@ <h2 id="7-SpringBoot微服务打包成镜像"><a href="#7-SpringBoot微服务打

<div class="card-action article-tags">

<a href="/tags/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/">
<span class="chip bg-color">操作系统</span>
<a href="/tags/Linux/">
<span class="chip bg-color">Linux</span>
</a>

</div>
Expand Down
20 changes: 8 additions & 12 deletions 2024/01/24/Dubbo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -914,18 +914,18 @@ <h1 id="Dubbo"><a href="#Dubbo" class="headerlink" title="Dubbo"></a>Dubbo</h1>
下一篇&nbsp;<i class="fas fa-chevron-right"></i>
</div>
<div class="card">
<a href="/2024/01/24/Homebrew/">
<a href="/2024/01/24/Frp/">
<div class="card-image">

<img src="/markdownimages/background/animation/4.jpg" class="responsive-img" alt="Homebrew">
<img src="/markdownimages/background/animation/16.jpeg" class="responsive-img" alt="Frp">

<span class="card-title">Homebrew</span>
<span class="card-title">Frp</span>
</div>
</a>
<div class="card-content article-content">
<div class="summary block-with-text">

Homebrew
Frp

</div>
<div class="publish-info">
Expand All @@ -936,8 +936,8 @@ <h1 id="Dubbo"><a href="#Dubbo" class="headerlink" title="Dubbo"></a>Dubbo</h1>

<i class="fas fa-bookmark fa-fw icon-category"></i>

<a href="/categories/Homebrew/" class="post-category">
Homebrew
<a href="/categories/%E4%BB%A3%E7%90%86/" class="post-category">
代理
</a>


Expand All @@ -947,12 +947,8 @@ <h1 id="Dubbo"><a href="#Dubbo" class="headerlink" title="Dubbo"></a>Dubbo</h1>

<div class="card-action article-tags">

<a href="/tags/Homebrew/">
<span class="chip bg-color">Homebrew</span>
</a>

<a href="/tags/Mac/">
<span class="chip bg-color">Mac</span>
<a href="/tags/Frp/">
<span class="chip bg-color">Frp</span>
</a>

</div>
Expand Down
Loading

0 comments on commit 9b485a1

Please sign in to comment.