update doc

gh-pages
hengyunabc 5 years ago
parent c1dcc8ff9e
commit f599c74408

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>&lt;no title&gt; &mdash; Arthas 3.4.1 文档</title> <title>&lt;no title&gt; &mdash; Arthas 3.4.2 文档</title>
@ -72,7 +72,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 976 KiB

After

Width:  |  Height:  |  Size: 791 KiB

@ -18,53 +18,65 @@ dashboard
``` ```
$ dashboard $ dashboard
ID NAME GROUP PRIORITY STATE %CPU TIME INTERRUPTED DAEMON ID NAME GROUP PRIORITY STATE %CPU DELTA_TIME TIME INTERRUPTE DAEMON
889 RMI TCP Connection(15)-30.10.166. RMI Runtime 9 RUNNABLE 48 0:5 false true -1 C2 CompilerThread0 - -1 - 1.55 0.077 0:8.684 false true
1077 Timer-for-arthas-dashboard-0 system 9 RUNNABLE 24 0:0 false true 53 Timer-for-arthas-dashboard-07b system 5 RUNNABLE 0.08 0.004 0:0.004 false true
1074 as-selector-daemon system 9 RUNNABLE 12 0:0 false true 22 scheduling-1 main 5 TIMED_WAI 0.06 0.003 0:0.287 false false
284 JMX server connection timeout 284 RMI Runtime 9 TIMED_WAITI 8 0:3 false true -1 C1 CompilerThread0 - -1 - 0.06 0.003 0:2.171 false true
16 Timer-1 main 5 TIMED_WAITI 5 0:9 false true -1 VM Periodic Task Thread - -1 - 0.03 0.001 0:0.092 false true
47 Pandora pandora-qos-reporter Pool main 5 TIMED_WAITI 0 0:0 false true 49 arthas-NettyHttpTelnetBootstra system 5 RUNNABLE 0.02 0.001 0:0.156 false true
48 JmonitorClient-CheckThread Pool [ main 5 TIMED_WAITI 0 0:0 false true 16 Catalina-utility-1 main 1 TIMED_WAI 0.0 0.000 0:0.029 false false
49 JmonitorClient-HeartBeat Pool [Th main 5 TIMED_WAITI 0 0:0 false true -1 G1 Young RemSet Sampling - -1 - 0.0 0.000 0:0.019 false true
50 JmonitorClient-ReaderThread Pool main 5 TIMED_WAITI 0 0:0 false true 17 Catalina-utility-2 main 1 WAITING 0.0 0.000 0:0.025 false false
957 RMI TCP Connection(16)-30.10.166. RMI Runtime 9 RUNNABLE 0 0:2 false true 34 http-nio-8080-ClientPoller main 5 RUNNABLE 0.0 0.000 0:0.016 false true
51 JmonitorClient-WriterThread Pool main 5 TIMED_WAITI 0 0:0 false true 23 http-nio-8080-BlockPoller main 5 RUNNABLE 0.0 0.000 0:0.011 false true
52 ContainerBackgroundProcessor[Stan main 5 TIMED_WAITI 0 0:0 false true -1 VM Thread - -1 - 0.0 0.000 0:0.032 false true
53 http-bio-8080-Acceptor-0 main 5 RUNNABLE 0 0:2 false true -1 Service Thread - -1 - 0.0 0.000 0:0.006 false true
54 http-bio-8080-AsyncTimeout main 5 TIMED_WAITI 0 0:0 false true -1 GC Thread#5 - -1 - 0.0 0.000 0:0.043 false true
11 GC Daemon system 2 TIMED_WAITI 0 0:0 false true
Memory used total max usage GC Memory used total max usage GC
heap 59M 223M 1820M 3.26% gc.ps_scavenge.count 118 heap 36M 70M 4096M 0.90% gc.g1_young_generation.count 12
ps_eden_space 14M 114M 668M 2.11% gc.ps_scavenge.time(ms) 1890 g1_eden_space 6M 18M -1 33.33% 86
ps_survivor_space 6M 6M 6M 96.08% gc.ps_marksweep.count 5 g1_old_gen 30M 50M 4096M 0.74% gc.g1_old_generation.count 0
ps_old_gen 39M 103M 1365M 2.86% gc.ps_marksweep.time(ms) 1140 g1_survivor_space 491K 2048K -1 24.01% gc.g1_old_generation.time(ms) 0
nonheap 234M 240M 0M 97.46% nonheap 66M 69M -1 96.56%
code_cache 46M 47M 240M 19.49% codeheap_'non-nmethods' 1M 2M 5M 22.39%
metaspace 167M 172M 0M 97.36% metaspace 46M 47M -1 98.01%
Runtime Tomcat Runtime
os.name Mac OS X connector http-bio-8080 os.name Mac OS X
os.version 10.10.5 QPS 0.00 os.version 10.15.4
java.version 1.8.0_60 RT(ms) 1.13 java.version 15
java.home error/s 0.00 java.home /Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home
received/s 0B systemload.average 10.68
systemload.average 3.44 sent/s 0B processors 8
processors 4 threadpool http-bio-8080 uptime 272s
uptime 16020s busy 0
``` ```
### 数据说明 ### 数据说明
* ID: Java级别的线程ID注意这个ID不能跟jstack中的nativeID一一对应 * ID: Java级别的线程ID注意这个ID不能跟jstack中的nativeID一一对应
* NAME: 线程名 * NAME: 线程名
* GROUP: 线程组名 * GROUP: 线程组名
* PRIORITY: 线程优先级, 1~10之间的数字越大表示优先级越高 * PRIORITY: 线程优先级, 1~10之间的数字越大表示优先级越高
* STATE: 线程的状态 * STATE: 线程的状态
* CPU%: 线程消耗的cpu占比采样100ms将所有线程在这100ms内的cpu使用量求和再算出每个线程的cpu使用占比。 * CPU%: 线程的cpu使用率。比如采样间隔1000ms某个线程的增量cpu时间为100ms则cpu使用率=100/1000=10%
* TIME: 线程运行总时间,数据格式为`分:秒` * DELTA_TIME: 上次采样之后线程运行增量CPU时间数据格式为`秒`
* TIME: 线程运行总CPU时间数据格式为`分:秒`
* INTERRUPTED: 线程当前的中断位状态 * INTERRUPTED: 线程当前的中断位状态
* DAEMON: 是否是daemon线程 * DAEMON: 是否是daemon线程
#### JVM内部线程
Java 8之后支持获取JVM内部线程CPU时间这些线程只有名称和CPU时间没有ID及状态等信息显示ID为-1
通过内部线程可以观测到JVM活动如GC、JIT编译等占用CPU情况方便了解JVM整体运行状况。
* 当JVM 堆(heap)/元数据(metaspace)空间不足或OOM时可以看到GC线程的CPU占用率明显高于其他的线程。
* 当执行`trace/watch/tt/redefine`等命令后可以看到JIT线程活动变得更频繁。因为JVM热更新class字节码时清除了此class相关的JIT编译结果需要重新编译。
JVM内部线程包括下面几种
* JIT编译线程: 如 `C1 CompilerThread0`, `C2 CompilerThread0`
* GC线程: 如`GC Thread0`, `G1 Young RemSet Sampling`
* 其它内部线程: 如`VM Periodic Task Thread`, `VM Thread`, `Service Thread`
### 截图展示 ### 截图展示
![](_static/dashboard.png "dashboard") ![](_static/dashboard.png "dashboard")

@ -13,16 +13,23 @@ thread
|*id*|线程id| |*id*|线程id|
|[n:]|指定最忙的前N个线程并打印堆栈| |[n:]|指定最忙的前N个线程并打印堆栈|
|[b]|找出当前阻塞其他线程的线程| |[b]|找出当前阻塞其他线程的线程|
|[i `<value>`]|指定cpu占比统计的采样间隔单位为毫秒| |[i `<value>`]|指定cpu使用率统计的采样间隔单位为毫秒默认值为200|
|[--all]|显示所有匹配的线程|
> cpu占比是如何统计出来的? ### cpu使用率是如何统计出来的?
> 这里的cpu统计的是一段采样间隔内当前JVM里各个线程所占用的cpu时间占总cpu时间的百分比。其计算方法为 这里的cpu使用率与linux 命令`top -H -p <pid>` 的线程`%CPU`类似一段采样间隔时间内当前JVM里各个线程的增量cpu时间与采样间隔时间的比例。
> 首先进行一次采样获得所有线程的cpu的使用时间(调用的是`java.lang.management.ThreadMXBean#getThreadCpuTime`这个接口)然后睡眠一段时间默认100ms可以通过`-i`参数指定然后再采样一次最后得出这段时间内各个线程消耗的cpu时间情况最后算出百分比。
#### 工作原理说明:
* 首先第一次采样获取所有线程的CPU时间(调用的是`java.lang.management.ThreadMXBean#getThreadCpuTime()`及`sun.management.HotspotThreadMBean.getInternalThreadCpuTimes()`接口)
* 然后睡眠等待一个间隔时间默认为200ms可以通过`-i`指定间隔时间)
* 再次第二次采样获取所有线程的CPU时间对比两次采样数据计算出每个线程的增量CPU时间
* 线程CPU使用率 = 线程增量CPU时间 / 采样间隔时间 * 100%
> 注意: 这个统计也会产生一定的开销JDK这个接口本身开销比较大因此会看到as的线程占用一定的百分比为了降低统计自身的开销带来的影响可以把采样间隔拉长一些比如5000毫秒。 > 注意: 这个统计也会产生一定的开销JDK这个接口本身开销比较大因此会看到as的线程占用一定的百分比为了降低统计自身的开销带来的影响可以把采样间隔拉长一些比如5000毫秒。
> 如果想看从Java进程启动开始到现在的cpu占比情况可以使用[show-busy-java-threads](https://github.com/oldratlee/useful-scripts/blob/master/docs/java.md#-show-busy-java-threads)这个脚本 > 另外一种查看Java进程的线程cpu使用率方法:可以使用[show-busy-java-threads](https://github.com/oldratlee/useful-scripts/blob/master/docs/java.md#-show-busy-java-threads)这个脚本
### 使用参考 ### 使用参考
@ -30,60 +37,70 @@ thread
```shell ```shell
$ thread -n 3 $ thread -n 3
"as-command-execute-daemon" Id=29 cpuUsage=75% RUNNABLE "C1 CompilerThread0" [Internal] cpuUsage=1.63% deltaTime=3ms time=1170ms
at sun.management.ThreadImpl.dumpThreads0(Native Method)
at sun.management.ThreadImpl.getThreadInfo(ThreadImpl.java:440)
at com.taobao.arthas.core.command.monitor200.ThreadCommand$1.action(ThreadCommand.java:58) "arthas-command-execute" Id=23 cpuUsage=0.11% deltaTime=0ms time=401ms RUNNABLE
at com.taobao.arthas.core.command.handler.AbstractCommandHandler.execute(AbstractCommandHandler.java:238) at java.management@11.0.7/sun.management.ThreadImpl.dumpThreads0(Native Method)
at com.taobao.arthas.core.command.handler.DefaultCommandHandler.handleCommand(DefaultCommandHandler.java:67) at java.management@11.0.7/sun.management.ThreadImpl.getThreadInfo(ThreadImpl.java:466)
at com.taobao.arthas.core.server.ArthasServer$4.run(ArthasServer.java:276) at com.taobao.arthas.core.command.monitor200.ThreadCommand.processTopBusyThreads(ThreadCommand.java:199)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at com.taobao.arthas.core.command.monitor200.ThreadCommand.process(ThreadCommand.java:122)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl.process(AnnotatedCommandImpl.java:82)
at java.lang.Thread.run(Thread.java:745) at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl.access$100(AnnotatedCommandImpl.java:18)
at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl$ProcessHandler.handle(AnnotatedCommandImpl.java:111)
Number of locked synchronizers = 1 at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl$ProcessHandler.handle(AnnotatedCommandImpl.java:108)
- java.util.concurrent.ThreadPoolExecutor$Worker@6cd0b6f8 at com.taobao.arthas.core.shell.system.impl.ProcessImpl$CommandProcessTask.run(ProcessImpl.java:385)
at java.base@11.0.7/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base@11.0.7/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base@11.0.7/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
at java.base@11.0.7/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base@11.0.7/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base@11.0.7/java.lang.Thread.run(Thread.java:834)
"VM Periodic Task Thread" [Internal] cpuUsage=0.07% deltaTime=0ms time=584ms
```
"as-session-expire-daemon" Id=25 cpuUsage=24% TIMED_WAITING * 没有线程ID包含`[Internal]`表示为JVM内部线程参考[dashboard](dashboard.md)命令的介绍。
at java.lang.Thread.sleep(Native Method) * `cpuUsage`为采样间隔时间内线程的CPU使用率与[dashboard](dashboard.md)命令的数据一致。
at com.taobao.arthas.core.server.DefaultSessionManager$2.run(DefaultSessionManager.java:85) * `deltaTime`为采样间隔时间内线程的增量CPU时间小于1ms时被取整显示为0ms。
* `time` 线程运行总CPU时间。
注意:线程栈为第二采样结束时获取,不能表明采样间隔时间内该线程都是在处理相同的任务。建议间隔时间不要太长,可能间隔时间越大越不准确。
可以根据具体情况尝试指定不同的间隔时间,观察输出结果。
#### 当没有参数时,显示第一页线程的信息
"Reference Handler" Id=2 cpuUsage=0% WAITING on java.lang.ref.Reference$Lock@69ba0f27 默认按照CPU增量时间降序排列只显示第一页数据。
at java.lang.Object.wait(Native Method)
- waiting on java.lang.ref.Reference$Lock@69ba0f27
at java.lang.Object.wait(Object.java:503)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)
```
#### 当没有参数时,显示所有线程的信息。
```shell ```shell
$ thread $ thread
Threads Total: 16, NEW: 0, RUNNABLE: 7, BLOCKED: 0, WAITING: 5, TIMED_WAITING: 4, TERMINATED: 0 Threads Total: 33, NEW: 0, RUNNABLE: 9, BLOCKED: 0, WAITING: 3, TIMED_WAITING: 4, TERMINATED: 0, Internal threads: 17
ID NAME GROUP PRIORITY STATE %CPU TIME INTERRUPTE DAEMON ID NAME GROUP PRIORITY STATE %CPU DELTA_TIME TIME INTERRUPT DAEMON
30 as-command-execute-daemon system 9 RUNNABLE 72 0:0 false true -1 C2 CompilerThread0 - -1 - 5.06 0.010 0:0.973 false true
23 as-session-expire-daemon system 9 TIMED_WAIT 27 0:0 false true -1 C1 CompilerThread0 - -1 - 0.95 0.001 0:0.603 false true
22 Attach Listener system 9 RUNNABLE 0 0:0 false true 23 arthas-command-execute system 5 RUNNABLE 0.17 0.000 0:0.226 false true
11 pool-2-thread-1 main 5 TIMED_WAIT 0 0:0 false false -1 VM Periodic Task Thread - -1 - 0.05 0.000 0:0.094 false true
12 Thread-2 main 5 RUNNABLE 0 0:0 false true -1 Sweeper thread - -1 - 0.04 0.000 0:0.011 false true
13 pool-3-thread-1 main 5 TIMED_WAIT 0 0:0 false false -1 G1 Young RemSet Sampling - -1 - 0.02 0.000 0:0.025 false true
25 as-selector-daemon system 9 RUNNABLE 0 0:0 false true 12 Attach Listener system 9 RUNNABLE 0.0 0.000 0:0.022 false true
14 Thread-3 main 5 TIMED_WAIT 0 0:0 false false 11 Common-Cleaner InnocuousThrea 8 TIMED_WAI 0.0 0.000 0:0.000 false true
26 pool-5-thread-1 system 5 WAITING 0 0:0 false false 3 Finalizer system 8 WAITING 0.0 0.000 0:0.000 false true
15 Thread-4 main 5 RUNNABLE 0 0:0 false false 2 Reference Handler system 10 RUNNABLE 0.0 0.000 0:0.000 false true
1 main main 5 WAITING 0 0:2 false false 4 Signal Dispatcher system 9 RUNNABLE 0.0 0.000 0:0.000 false true
2 Reference Handler system 10 WAITING 0 0:0 false true 15 arthas-NettyHttpTelnetBootstra system 5 RUNNABLE 0.0 0.000 0:0.029 false true
3 Finalizer system 8 WAITING 0 0:0 false true 22 arthas-NettyHttpTelnetBootstra system 5 RUNNABLE 0.0 0.000 0:0.196 false true
4 Signal Dispatcher system 9 RUNNABLE 0 0:0 false true 24 arthas-NettyHttpTelnetBootstra system 5 RUNNABLE 0.0 0.000 0:0.038 false true
20 NonBlockingInputStreamThread main 5 WAITING 0 0:0 false true 16 arthas-NettyWebsocketTtyBootst system 5 RUNNABLE 0.0 0.000 0:0.001 false true
21 Thread-8 main 5 RUNNABLE 0 0:0 false true 17 arthas-NettyWebsocketTtyBootst system 5 RUNNABLE 0.0 0.000 0:0.001 false true
``` ```
#### thread id 显示指定线程的运行堆栈 #### thread --all, 显示所有匹配的线程
显示所有匹配线程信息有时需要获取全部JVM的线程数据进行分析。
#### thread id, 显示指定线程的运行堆栈
```shell ```shell
$ thread 1 $ thread 1
@ -145,6 +162,10 @@ $ thread -b
#### thread -i, 指定采样时间间隔 #### thread -i, 指定采样时间间隔
* `thread -i 1000` : 统计最近1000ms内的线程CPU时间。
* `thread -n 3 -i 1000` : 列出1000ms内最忙的3个线程栈
```bash ```bash
$ thread -n 3 -i 1000 $ thread -n 3 -i 1000
"as-command-execute-daemon" Id=4759 cpuUsage=23% RUNNABLE "as-command-execute-daemon" Id=4759 cpuUsage=23% RUNNABLE
@ -170,11 +191,9 @@ $ thread -n 3 -i 1000
```bash ```bash
[arthas@28114]$ thread --state WAITING [arthas@28114]$ thread --state WAITING
Threads Total: 15, NEW: 0, RUNNABLE: 7, BLOCKED: 0, WAITING: 5, TIMED_WAITING: 3, TERMINATED: 0 Threads Total: 16, NEW: 0, RUNNABLE: 9, BLOCKED: 0, WAITING: 3, TIMED_WAITING: 4, TERMINATED: 0
ID NAME GROUP PRIORITY STATE %CPU TIME INTERRU DAEMON ID NAME GROUP PRIORITY STATE %CPU DELTA_TIME TIME INTERRUPTE DAEMON
198 AsyncAppender-Worker-arth system 9 WAITING 0 0:0 false true 3 Finalizer system 8 WAITING 0.0 0.000 0:0.000 false true
3 Finalizer system 8 WAITING 0 0:0 false true 20 arthas-UserStat system 9 WAITING 0.0 0.000 0:0.001 false true
14 RMI Scheduler(0) system 9 WAITING 0 0:0 false true 14 arthas-timer system 9 WAITING 0.0 0.000 0:0.000 false true
2 Reference Handler system 10 WAITING 0 0:0 false true
204 pool-8-thread-1 system 5 WAITING 0 0:0 false false
``` ```

Binary file not shown.

Before

Width:  |  Height:  |  Size: 976 KiB

After

Width:  |  Height:  |  Size: 791 KiB

@ -1,6 +1,6 @@
var DOCUMENTATION_OPTIONS = { var DOCUMENTATION_OPTIONS = {
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'), URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
VERSION: '3.4.1', VERSION: '3.4.2',
LANGUAGE: 'zh_CN', LANGUAGE: 'zh_CN',
COLLAPSE_INDEX: false, COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html', FILE_SUFFIX: '.html',

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>进阶使用 &mdash; Arthas 3.4.1 文档</title> <title>进阶使用 &mdash; Arthas 3.4.2 文档</title>
@ -74,7 +74,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>表达式核心变量 &mdash; Arthas 3.4.1 文档</title> <title>表达式核心变量 &mdash; Arthas 3.4.2 文档</title>
@ -72,7 +72,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>以Java Agent的方式启动 &mdash; Arthas 3.4.1 文档</title> <title>以Java Agent的方式启动 &mdash; Arthas 3.4.2 文档</title>
@ -74,7 +74,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Arthas Properties &mdash; Arthas 3.4.1 文档</title> <title>Arthas Properties &mdash; Arthas 3.4.2 文档</title>
@ -74,7 +74,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Arthas3.0的新特性 &mdash; Arthas 3.4.1 文档</title> <title>Arthas3.0的新特性 &mdash; Arthas 3.4.2 文档</title>
@ -72,7 +72,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Arthas 3.0新特性介绍 &mdash; Arthas 3.4.1 文档</title> <title>Arthas 3.0新特性介绍 &mdash; Arthas 3.4.2 文档</title>
@ -72,7 +72,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Arthas后台异步任务 &mdash; Arthas 3.4.1 文档</title> <title>Arthas后台异步任务 &mdash; Arthas 3.4.2 文档</title>
@ -74,7 +74,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>批处理功能 &mdash; Arthas 3.4.1 文档</title> <title>批处理功能 &mdash; Arthas 3.4.2 文档</title>
@ -74,7 +74,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>cat &mdash; Arthas 3.4.1 文档</title> <title>cat &mdash; Arthas 3.4.2 文档</title>
@ -74,7 +74,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>classloader &mdash; Arthas 3.4.1 文档</title> <title>classloader &mdash; Arthas 3.4.2 文档</title>
@ -74,7 +74,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>命令列表 &mdash; Arthas 3.4.1 文档</title> <title>命令列表 &mdash; Arthas 3.4.2 文档</title>
@ -74,7 +74,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>联系我们 &mdash; Arthas 3.4.1 文档</title> <title>联系我们 &mdash; Arthas 3.4.2 文档</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>dashboard &mdash; Arthas 3.4.1 文档</title> <title>dashboard &mdash; Arthas 3.4.2 文档</title>
@ -74,7 +74,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>
@ -111,7 +111,10 @@
<li class="toctree-l2 current"><a class="current reference internal" href="#">dashboard</a><ul> <li class="toctree-l2 current"><a class="current reference internal" href="#">dashboard</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id1">参数说明</a></li> <li class="toctree-l3"><a class="reference internal" href="#id1">参数说明</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id2">使用参考</a></li> <li class="toctree-l3"><a class="reference internal" href="#id2">使用参考</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id3">数据说明</a></li> <li class="toctree-l3"><a class="reference internal" href="#id3">数据说明</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#jvm">JVM内部线程</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#id4">截图展示</a></li> <li class="toctree-l3"><a class="reference internal" href="#id4">截图展示</a></li>
</ul> </ul>
</li> </li>
@ -257,54 +260,68 @@
<div class="section" id="id2"> <div class="section" id="id2">
<h2>使用参考<a class="headerlink" href="#id2" title="永久链接至标题"></a></h2> <h2>使用参考<a class="headerlink" href="#id2" title="永久链接至标题"></a></h2>
<div class="highlight-default notranslate"><pre class="literal-block">$ dashboard <div class="highlight-default notranslate"><pre class="literal-block">$ dashboard
ID NAME GROUP PRIORITY STATE %CPU TIME INTERRUPTED DAEMON ID NAME GROUP PRIORITY STATE %CPU DELTA_TIME TIME INTERRUPTE DAEMON
889 RMI TCP Connection(15)-30.10.166. RMI Runtime 9 RUNNABLE 48 0:5 false true -1 C2 CompilerThread0 - -1 - 1.55 0.077 0:8.684 false true
1077 Timer-for-arthas-dashboard-0 system 9 RUNNABLE 24 0:0 false true 53 Timer-for-arthas-dashboard-07b system 5 RUNNABLE 0.08 0.004 0:0.004 false true
1074 as-selector-daemon system 9 RUNNABLE 12 0:0 false true 22 scheduling-1 main 5 TIMED_WAI 0.06 0.003 0:0.287 false false
284 JMX server connection timeout 284 RMI Runtime 9 TIMED_WAITI 8 0:3 false true -1 C1 CompilerThread0 - -1 - 0.06 0.003 0:2.171 false true
16 Timer-1 main 5 TIMED_WAITI 5 0:9 false true -1 VM Periodic Task Thread - -1 - 0.03 0.001 0:0.092 false true
47 Pandora pandora-qos-reporter Pool main 5 TIMED_WAITI 0 0:0 false true 49 arthas-NettyHttpTelnetBootstra system 5 RUNNABLE 0.02 0.001 0:0.156 false true
48 JmonitorClient-CheckThread Pool [ main 5 TIMED_WAITI 0 0:0 false true 16 Catalina-utility-1 main 1 TIMED_WAI 0.0 0.000 0:0.029 false false
49 JmonitorClient-HeartBeat Pool [Th main 5 TIMED_WAITI 0 0:0 false true -1 G1 Young RemSet Sampling - -1 - 0.0 0.000 0:0.019 false true
50 JmonitorClient-ReaderThread Pool main 5 TIMED_WAITI 0 0:0 false true 17 Catalina-utility-2 main 1 WAITING 0.0 0.000 0:0.025 false false
957 RMI TCP Connection(16)-30.10.166. RMI Runtime 9 RUNNABLE 0 0:2 false true 34 http-nio-8080-ClientPoller main 5 RUNNABLE 0.0 0.000 0:0.016 false true
51 JmonitorClient-WriterThread Pool main 5 TIMED_WAITI 0 0:0 false true 23 http-nio-8080-BlockPoller main 5 RUNNABLE 0.0 0.000 0:0.011 false true
52 ContainerBackgroundProcessor[Stan main 5 TIMED_WAITI 0 0:0 false true -1 VM Thread - -1 - 0.0 0.000 0:0.032 false true
53 http-bio-8080-Acceptor-0 main 5 RUNNABLE 0 0:2 false true -1 Service Thread - -1 - 0.0 0.000 0:0.006 false true
54 http-bio-8080-AsyncTimeout main 5 TIMED_WAITI 0 0:0 false true -1 GC Thread#5 - -1 - 0.0 0.000 0:0.043 false true
11 GC Daemon system 2 TIMED_WAITI 0 0:0 false true
Memory used total max usage GC Memory used total max usage GC
heap 59M 223M 1820M 3.26% gc.ps_scavenge.count 118 heap 36M 70M 4096M 0.90% gc.g1_young_generation.count 12
ps_eden_space 14M 114M 668M 2.11% gc.ps_scavenge.time(ms) 1890 g1_eden_space 6M 18M -1 33.33% 86
ps_survivor_space 6M 6M 6M 96.08% gc.ps_marksweep.count 5 g1_old_gen 30M 50M 4096M 0.74% gc.g1_old_generation.count 0
ps_old_gen 39M 103M 1365M 2.86% gc.ps_marksweep.time(ms) 1140 g1_survivor_space 491K 2048K -1 24.01% gc.g1_old_generation.time(ms) 0
nonheap 234M 240M 0M 97.46% nonheap 66M 69M -1 96.56%
code_cache 46M 47M 240M 19.49% codeheap_&#x27;non-nmethods&#x27; 1M 2M 5M 22.39%
metaspace 167M 172M 0M 97.36% metaspace 46M 47M -1 98.01%
Runtime Tomcat Runtime
os.name Mac OS X connector http-bio-8080 os.name Mac OS X
os.version 10.10.5 QPS 0.00 os.version 10.15.4
java.version 1.8.0_60 RT(ms) 1.13 java.version 15
java.home error/s 0.00 java.home /Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home
received/s 0B systemload.average 10.68
systemload.average 3.44 sent/s 0B processors 8
processors 4 threadpool http-bio-8080 uptime 272s</pre>
uptime 16020s busy 0</pre>
</div> </div>
</div> </div>
<div class="section" id="id3"> <div class="section" id="id3">
<h2>数据说明<a class="headerlink" href="#id3" title="永久链接至标题"></a></h2> <h2>数据说明<a class="headerlink" href="#id3" title="永久链接至标题"></a></h2>
<ul class="simple"> <ul class="simple">
<li><p>ID: Java级别的线程ID注意这个ID不能跟jstack中的nativeID一一对应</p></li> <li><p>ID: Java级别的线程ID注意这个ID不能跟jstack中的nativeID一一对应</p></li>
<li><p>NAME: 线程名</p></li> <li><p>NAME: 线程名</p></li>
<li><p>GROUP: 线程组名</p></li> <li><p>GROUP: 线程组名</p></li>
<li><p>PRIORITY: 线程优先级, 1~10之间的数字越大表示优先级越高</p></li> <li><p>PRIORITY: 线程优先级, 1~10之间的数字越大表示优先级越高</p></li>
<li><p>STATE: 线程的状态</p></li> <li><p>STATE: 线程的状态</p></li>
<li><p>CPU%: 线程消耗的cpu占比采样100ms将所有线程在这100ms内的cpu使用量求和再算出每个线程的cpu使用占比。</p></li> <li><p>CPU%: 线程的cpu使用率。比如采样间隔1000ms某个线程的增量cpu时间为100ms则cpu使用率=100/1000=10%</p></li>
<li><p>TIME: 线程运行总时间,数据格式为<code class="docutils literal notranslate"><span class="pre">分:秒</span></code></p></li> <li><p>DELTA_TIME: 上次采样之后线程运行增量CPU时间数据格式为<code class="docutils literal notranslate"><span class="pre"></span></code></p></li>
<li><p>TIME: 线程运行总CPU时间数据格式为<code class="docutils literal notranslate"><span class="pre">分:秒</span></code></p></li>
<li><p>INTERRUPTED: 线程当前的中断位状态</p></li> <li><p>INTERRUPTED: 线程当前的中断位状态</p></li>
<li><p>DAEMON: 是否是daemon线程</p></li> <li><p>DAEMON: 是否是daemon线程</p></li>
</ul> </ul>
<div class="section" id="jvm">
<h3>JVM内部线程<a class="headerlink" href="#jvm" title="永久链接至标题"></a></h3>
<p>Java 8之后支持获取JVM内部线程CPU时间这些线程只有名称和CPU时间没有ID及状态等信息显示ID为-1
通过内部线程可以观测到JVM活动如GC、JIT编译等占用CPU情况方便了解JVM整体运行状况。</p>
<ul class="simple">
<li><p>当JVM 堆(heap)/元数据(metaspace)空间不足或OOM时可以看到GC线程的CPU占用率明显高于其他的线程。</p></li>
<li><p>当执行<code class="docutils literal notranslate"><span class="pre">trace/watch/tt/redefine</span></code>等命令后可以看到JIT线程活动变得更频繁。因为JVM热更新class字节码时清除了此class相关的JIT编译结果需要重新编译。</p></li>
</ul>
<p>JVM内部线程包括下面几种</p>
<ul class="simple">
<li><p>JIT编译线程: 如 <code class="docutils literal notranslate"><span class="pre">C1</span> <span class="pre">CompilerThread0</span></code>, <code class="docutils literal notranslate"><span class="pre">C2</span> <span class="pre">CompilerThread0</span></code></p></li>
<li><p>GC线程: 如<code class="docutils literal notranslate"><span class="pre">GC</span> <span class="pre">Thread0</span></code>, <code class="docutils literal notranslate"><span class="pre">G1</span> <span class="pre">Young</span> <span class="pre">RemSet</span> <span class="pre">Sampling</span></code></p></li>
<li><p>其它内部线程: 如<code class="docutils literal notranslate"><span class="pre">VM</span> <span class="pre">Periodic</span> <span class="pre">Task</span> <span class="pre">Thread</span></code>, <code class="docutils literal notranslate"><span class="pre">VM</span> <span class="pre">Thread</span></code>, <code class="docutils literal notranslate"><span class="pre">Service</span> <span class="pre">Thread</span></code></p></li>
</ul>
</div>
</div> </div>
<div class="section" id="id4"> <div class="section" id="id4">
<h2>截图展示<a class="headerlink" href="#id4" title="永久链接至标题"></a></h2> <h2>截图展示<a class="headerlink" href="#id4" title="永久链接至标题"></a></h2>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Docker &mdash; Arthas 3.4.1 文档</title> <title>Docker &mdash; Arthas 3.4.2 文档</title>
@ -74,7 +74,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>下载 &mdash; Arthas 3.4.1 文档</title> <title>下载 &mdash; Arthas 3.4.2 文档</title>
@ -74,7 +74,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>dump &mdash; Arthas 3.4.1 文档</title> <title>dump &mdash; Arthas 3.4.2 文档</title>
@ -74,7 +74,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>echo &mdash; Arthas 3.4.1 文档</title> <title>echo &mdash; Arthas 3.4.2 文档</title>
@ -74,7 +74,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -1,4 +1,4 @@
# Sphinx build info version 1 # Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 7c21ccbfdaf6e0577e389109c77b5c66 config: 6fa057b4649087e17d0a5ad55f4c47c1
tags: 645f666f9bcd5a90fca523b33c5a78b7 tags: 645f666f9bcd5a90fca523b33c5a78b7

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>&lt;no title&gt; &mdash; Arthas 3.4.1 documentation</title> <title>&lt;no title&gt; &mdash; Arthas 3.4.2 documentation</title>
@ -71,7 +71,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 976 KiB

After

Width:  |  Height:  |  Size: 791 KiB

@ -18,39 +18,37 @@ When running in Apache Tomcat Alibaba edition, the dashboard will also present t
``` ```
$ dashboard $ dashboard
ID NAME GROUP PRIORITY STATE %CPU TIME INTERRUPTED DAEMON ID NAME GROUP PRIORITY STATE %CPU DELTA_TIME TIME INTERRUPTE DAEMON
889 RMI TCP Connection(15)-30.10.166. RMI Runtime 9 RUNNABLE 48 0:5 false true -1 C2 CompilerThread0 - -1 - 1.55 0.077 0:8.684 false true
1077 Timer-for-arthas-dashboard-0 system 9 RUNNABLE 24 0:0 false true 53 Timer-for-arthas-dashboard-07b system 5 RUNNABLE 0.08 0.004 0:0.004 false true
1074 as-selector-daemon system 9 RUNNABLE 12 0:0 false true 22 scheduling-1 main 5 TIMED_WAI 0.06 0.003 0:0.287 false false
284 JMX server connection timeout 284 RMI Runtime 9 TIMED_WAITI 8 0:3 false true -1 C1 CompilerThread0 - -1 - 0.06 0.003 0:2.171 false true
16 Timer-1 main 5 TIMED_WAITI 5 0:9 false true -1 VM Periodic Task Thread - -1 - 0.03 0.001 0:0.092 false true
47 Pandora pandora-qos-reporter Pool main 5 TIMED_WAITI 0 0:0 false true 49 arthas-NettyHttpTelnetBootstra system 5 RUNNABLE 0.02 0.001 0:0.156 false true
48 JmonitorClient-CheckThread Pool [ main 5 TIMED_WAITI 0 0:0 false true 16 Catalina-utility-1 main 1 TIMED_WAI 0.0 0.000 0:0.029 false false
49 JmonitorClient-HeartBeat Pool [Th main 5 TIMED_WAITI 0 0:0 false true -1 G1 Young RemSet Sampling - -1 - 0.0 0.000 0:0.019 false true
50 JmonitorClient-ReaderThread Pool main 5 TIMED_WAITI 0 0:0 false true 17 Catalina-utility-2 main 1 WAITING 0.0 0.000 0:0.025 false false
957 RMI TCP Connection(16)-30.10.166. RMI Runtime 9 RUNNABLE 0 0:2 false true 34 http-nio-8080-ClientPoller main 5 RUNNABLE 0.0 0.000 0:0.016 false true
51 JmonitorClient-WriterThread Pool main 5 TIMED_WAITI 0 0:0 false true 23 http-nio-8080-BlockPoller main 5 RUNNABLE 0.0 0.000 0:0.011 false true
52 ContainerBackgroundProcessor[Stan main 5 TIMED_WAITI 0 0:0 false true -1 VM Thread - -1 - 0.0 0.000 0:0.032 false true
53 http-bio-8080-Acceptor-0 main 5 RUNNABLE 0 0:2 false true -1 Service Thread - -1 - 0.0 0.000 0:0.006 false true
54 http-bio-8080-AsyncTimeout main 5 TIMED_WAITI 0 0:0 false true -1 GC Thread#5 - -1 - 0.0 0.000 0:0.043 false true
11 GC Daemon system 2 TIMED_WAITI 0 0:0 false true
Memory used total max usage GC Memory used total max usage GC
heap 59M 223M 1820M 3.26% gc.ps_scavenge.count 118 heap 36M 70M 4096M 0.90% gc.g1_young_generation.count 12
ps_eden_space 14M 114M 668M 2.11% gc.ps_scavenge.time(ms) 1890 g1_eden_space 6M 18M -1 33.33% 86
ps_survivor_space 6M 6M 6M 96.08% gc.ps_marksweep.count 5 g1_old_gen 30M 50M 4096M 0.74% gc.g1_old_generation.count 0
ps_old_gen 39M 103M 1365M 2.86% gc.ps_marksweep.time(ms) 1140 g1_survivor_space 491K 2048K -1 24.01% gc.g1_old_generation.time(ms) 0
nonheap 234M 240M 0M 97.46% nonheap 66M 69M -1 96.56%
code_cache 46M 47M 240M 19.49% codeheap_'non-nmethods' 1M 2M 5M 22.39%
metaspace 167M 172M 0M 97.36% metaspace 46M 47M -1 98.01%
Runtime Tomcat Runtime
os.name Mac OS X connector http-bio-8080 os.name Mac OS X
os.version 10.10.5 QPS 0.00 os.version 10.15.4
java.version 1.8.0_60 RT(ms) 1.13 java.version 15
java.home error/s 0.00 java.home /Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home
received/s 0B systemload.average 10.68
systemload.average 3.44 sent/s 0B processors 8
processors 4 threadpool http-bio-8080 uptime 272s
uptime 16020s busy 0
``` ```
### Notes on column headers ### Notes on column headers
@ -60,11 +58,31 @@ uptime 16020s busy
* GROUP: thread group name * GROUP: thread group name
* PRIORITY: thread priority, ranged from 1 to 10. The greater number, the higher priority * PRIORITY: thread priority, ranged from 1 to 10. The greater number, the higher priority
* STATE: thread state * STATE: thread state
* CPU%: the ratio of CPU usage for the thread, sampled every 100ms * CPU%: the ratio of CPU usage for the thread. For example, the sampling interval is 1000ms, and the incremental cpu time
* TIME: total running time in `minute:second` format of a thread is 100ms, then the cpu usage rate=100/1000=10%
* DELTA_TIME: incremental CPU time of thread running after the last sampling in `second` format
* TIME: total CPU time of the thread in `minute:second` format
* INTERRUPTED: the thread interruption state * INTERRUPTED: the thread interruption state
* DAEMON: daemon thread or not * DAEMON: daemon thread or not
#### JVM internal threads
After Java 8, it is supported to obtain the CPU time of JVM internal threads. These threads only have the name and CPU time,
without ID and status information (display ID is -1).
JVM activities can be observed through internal threads, such as GC, JIT compilation, etc., to perceive the overall status of JVM.
* When the JVM heap/metaspace space is insufficient or OOM, it can be seen that the CPU usage of the GC threads is
significantly higher than other threads.
* After executing commands such as `trace/watch/tt/redefine`, you can see that JIT threads activities become more frequent.
Because the JIT compilation data related to this class is cleared when the JVM hot update the class bytecode, it needs to be recompiled.
JVM internal threads include the following:
* JIT compilation thread: such as `C1 CompilerThread0`, `C2 CompilerThread0`
* GC thread: such as `GC Thread0`, `G1 Young RemSet Sampling`
* Other internal threads: such as`VM Periodic Task Thread`, `VM Thread`, `Service Thread`
### Screenshot ### Screenshot
![](../_static/dashboard.png "dashboard") ![](../_static/dashboard.png "dashboard")

@ -13,11 +13,23 @@ thread
|`[n:]`|the top n busiest threads with stack traces printed| |`[n:]`|the top n busiest threads with stack traces printed|
|`[b]`|locate the thread blocking the others| |`[b]`|locate the thread blocking the others|
|[i `<value>`]|specify the interval to collect data to compute CPU ratios (ms)| |[i `<value>`]|specify the interval to collect data to compute CPU ratios (ms)|
|[--all]|Show all matching threads|
> How the CPU ratios are calculated? <br/><br/> ### How the CPU ratios are calculated?
> CPU ratio for a given thread is the CPU time it takes divided by the total CPU time within a specified interval period. It is calculated in the following way: sample CPU times for all the thread by calling `java.lang.management.ThreadMXBean#getThreadCpuTime` first, then sleep for a period (the default value is 100ms, which can be specified by `-i`), then sample CPU times again. By this, we can get the time cost for this period for each thread, then come up with the ratio. <br/><br/>
> Note: this operation consumes CPU time too (`getThreadCpuTime` is time-consuming), therefore it is possible to observe Arthas's thread appears in the list. To avoid this, try to increase sample interval, for example: 5000 ms.<br/><br/> The cpu ratios here is similar to the thread `%CPU` of the linux command `top -H -p <pid>`. During a sampling interval,
> If you'd like to check the CPU ratios from the very beginning of the Java process, [show-busy-java-threads](https://github.com/oldratlee/useful-scripts/blob/master/docs/java.md#-show-busy-java-threads) can come to help. the ratio of the incremental cpu time of each thread in the current JVM to the sampling interval time.
> Working principle description:
* Do the first sampling, get the CPU time of all threads ( by calling `java.lang.management.ThreadMXBean#getThreadCpuTime()` and
`sun.management.HotspotThreadMBean.getInternalThreadCpuTimes()` )
* Sleep and wait for an interval (the default is 200ms, the interval can be specified by `-i`)
* Do the second sampling, get the CPU time of all threads, compare the two sampling data, and calculate the incremental CPU time of each thread
* `Thread CPU usage ratio` = `Thread increment CPU time` / `Sampling interval time` * 100%
> Note: this operation consumes CPU time too (`getThreadCpuTime` is time-consuming), therefore it is possible to observe Arthas's thread appears in the list. To avoid this, try to increase sample interval, for example: 5000 ms.<br/>
> Another way to view the thread cpu usage of the Java process, [show-busy-java-threads](https://github.com/oldratlee/useful-scripts/blob/master/docs/java.md#-show-busy-java-threads) can come to help.
### Usage ### Usage
@ -25,59 +37,72 @@ thread
```shell ```shell
$ thread -n 3 $ thread -n 3
"as-command-execute-daemon" Id=29 cpuUsage=75% RUNNABLE "C1 CompilerThread0" [Internal] cpuUsage=1.63% deltaTime=3ms time=1170ms
at sun.management.ThreadImpl.dumpThreads0(Native Method)
at sun.management.ThreadImpl.getThreadInfo(ThreadImpl.java:440)
at com.taobao.arthas.core.command.monitor200.ThreadCommand$1.action(ThreadCommand.java:58) "arthas-command-execute" Id=23 cpuUsage=0.11% deltaTime=0ms time=401ms RUNNABLE
at com.taobao.arthas.core.command.handler.AbstractCommandHandler.execute(AbstractCommandHandler.java:238) at java.management@11.0.7/sun.management.ThreadImpl.dumpThreads0(Native Method)
at com.taobao.arthas.core.command.handler.DefaultCommandHandler.handleCommand(DefaultCommandHandler.java:67) at java.management@11.0.7/sun.management.ThreadImpl.getThreadInfo(ThreadImpl.java:466)
at com.taobao.arthas.core.server.ArthasServer$4.run(ArthasServer.java:276) at com.taobao.arthas.core.command.monitor200.ThreadCommand.processTopBusyThreads(ThreadCommand.java:199)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at com.taobao.arthas.core.command.monitor200.ThreadCommand.process(ThreadCommand.java:122)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl.process(AnnotatedCommandImpl.java:82)
at java.lang.Thread.run(Thread.java:745) at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl.access$100(AnnotatedCommandImpl.java:18)
at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl$ProcessHandler.handle(AnnotatedCommandImpl.java:111)
Number of locked synchronizers = 1 at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl$ProcessHandler.handle(AnnotatedCommandImpl.java:108)
- java.util.concurrent.ThreadPoolExecutor$Worker@6cd0b6f8 at com.taobao.arthas.core.shell.system.impl.ProcessImpl$CommandProcessTask.run(ProcessImpl.java:385)
at java.base@11.0.7/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base@11.0.7/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base@11.0.7/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
at java.base@11.0.7/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base@11.0.7/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base@11.0.7/java.lang.Thread.run(Thread.java:834)
"VM Periodic Task Thread" [Internal] cpuUsage=0.07% deltaTime=0ms time=584ms
```
* Without thread ID, including `[Internal]` means JVM internal thread, refer to the introduction of [dashboard](dashboard.md) command.
* `cpuUsage` is the CPU usage of the thread during the sampling interval, consistent with the data of the [dashboard](dashboard.md) command.
* `deltaTime` is the incremental CPU time of the thread during the sampling interval. If it is less than 1ms, it will be rounded and displayed as 0ms.
* `time` The total CPU time of thread.
"as-session-expire-daemon" Id=25 cpuUsage=24% TIMED_WAITING **Note:** The thread stack is acquired at the end of the second sampling, which does not indicate that the thread is
at java.lang.Thread.sleep(Native Method) processing the same task during the sampling interval. It is recommended that the interval time should not be too long.
at com.taobao.arthas.core.server.DefaultSessionManager$2.run(DefaultSessionManager.java:85) The larger the interval time, the more inaccurate.
You can try to specify different intervals according to the specific situation and observe the output results.
"Reference Handler" Id=2 cpuUsage=0% WAITING on java.lang.ref.Reference$Lock@69ba0f27 #### List first page threads' info when no options provided
at java.lang.Object.wait(Native Method)
- waiting on java.lang.ref.Reference$Lock@69ba0f27
at java.lang.Object.wait(Object.java:503)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)
```
#### List all threads' info when no options provided By default, they are arranged in descending order of CPU increment time, and only the first page of data is displayed.
```shell ```shell
$ thread $ thread
Threads Total: 16, NEW: 0, RUNNABLE: 7, BLOCKED: 0, WAITING: 5, TIMED_WAITING: 4, TERMINATED: 0 Threads Total: 33, NEW: 0, RUNNABLE: 9, BLOCKED: 0, WAITING: 3, TIMED_WAITING: 4, TERMINATED: 0, Internal threads: 17
ID NAME GROUP PRIORITY STATE %CPU TIME INTERRUPTE DAEMON ID NAME GROUP PRIORITY STATE %CPU DELTA_TIME TIME INTERRUPT DAEMON
30 as-command-execute-daemon system 9 RUNNABLE 72 0:0 false true -1 C2 CompilerThread0 - -1 - 5.06 0.010 0:0.973 false true
23 as-session-expire-daemon system 9 TIMED_WAIT 27 0:0 false true -1 C1 CompilerThread0 - -1 - 0.95 0.001 0:0.603 false true
22 Attach Listener system 9 RUNNABLE 0 0:0 false true 23 arthas-command-execute system 5 RUNNABLE 0.17 0.000 0:0.226 false true
11 pool-2-thread-1 main 5 TIMED_WAIT 0 0:0 false false -1 VM Periodic Task Thread - -1 - 0.05 0.000 0:0.094 false true
12 Thread-2 main 5 RUNNABLE 0 0:0 false true -1 Sweeper thread - -1 - 0.04 0.000 0:0.011 false true
13 pool-3-thread-1 main 5 TIMED_WAIT 0 0:0 false false -1 G1 Young RemSet Sampling - -1 - 0.02 0.000 0:0.025 false true
25 as-selector-daemon system 9 RUNNABLE 0 0:0 false true 12 Attach Listener system 9 RUNNABLE 0.0 0.000 0:0.022 false true
14 Thread-3 main 5 TIMED_WAIT 0 0:0 false false 11 Common-Cleaner InnocuousThrea 8 TIMED_WAI 0.0 0.000 0:0.000 false true
26 pool-5-thread-1 system 5 WAITING 0 0:0 false false 3 Finalizer system 8 WAITING 0.0 0.000 0:0.000 false true
15 Thread-4 main 5 RUNNABLE 0 0:0 false false 2 Reference Handler system 10 RUNNABLE 0.0 0.000 0:0.000 false true
1 main main 5 WAITING 0 0:2 false false 4 Signal Dispatcher system 9 RUNNABLE 0.0 0.000 0:0.000 false true
2 Reference Handler system 10 WAITING 0 0:0 false true 15 arthas-NettyHttpTelnetBootstra system 5 RUNNABLE 0.0 0.000 0:0.029 false true
3 Finalizer system 8 WAITING 0 0:0 false true 22 arthas-NettyHttpTelnetBootstra system 5 RUNNABLE 0.0 0.000 0:0.196 false true
4 Signal Dispatcher system 9 RUNNABLE 0 0:0 false true 24 arthas-NettyHttpTelnetBootstra system 5 RUNNABLE 0.0 0.000 0:0.038 false true
20 NonBlockingInputStreamThread main 5 WAITING 0 0:0 false true 16 arthas-NettyWebsocketTtyBootst system 5 RUNNABLE 0.0 0.000 0:0.001 false true
21 Thread-8 main 5 RUNNABLE 0 0:0 false true 17 arthas-NettyWebsocketTtyBootst system 5 RUNNABLE 0.0 0.000 0:0.001 false true
``` ```
#### thread --all, show all matching threads
Display all matching threads. Sometimes it is necessary to obtain all the thread data of the JVM for analysis.
#### thread id, show the running stack for the target thread #### thread id, show the running stack for the target thread
```shell ```shell
@ -140,6 +165,10 @@ $ thread -b
#### thread -i, specify the sampling interval #### thread -i, specify the sampling interval
* `thread -i 1000`: Count the thread cpu time of the last 1000ms.
* `thread -n 3 -i 1000`: List the 3 busiest thread stacks in 1000ms
```bash ```bash
$ thread -n 3 -i 1000 $ thread -n 3 -i 1000
"as-command-execute-daemon" Id=4759 cpuUsage=23% RUNNABLE "as-command-execute-daemon" Id=4759 cpuUsage=23% RUNNABLE
@ -165,11 +194,9 @@ $ thread -n 3 -i 1000
```bash ```bash
[arthas@28114]$ thread --state WAITING [arthas@28114]$ thread --state WAITING
Threads Total: 15, NEW: 0, RUNNABLE: 7, BLOCKED: 0, WAITING: 5, TIMED_WAITING: 3, TERMINATED: 0 Threads Total: 16, NEW: 0, RUNNABLE: 9, BLOCKED: 0, WAITING: 3, TIMED_WAITING: 4, TERMINATED: 0
ID NAME GROUP PRIORITY STATE %CPU TIME INTERRU DAEMON ID NAME GROUP PRIORITY STATE %CPU DELTA_TIME TIME INTERRUPTE DAEMON
198 AsyncAppender-Worker-arth system 9 WAITING 0 0:0 false true 3 Finalizer system 8 WAITING 0.0 0.000 0:0.000 false true
3 Finalizer system 8 WAITING 0 0:0 false true 20 arthas-UserStat system 9 WAITING 0.0 0.000 0:0.001 false true
14 RMI Scheduler(0) system 9 WAITING 0 0:0 false true 14 arthas-timer system 9 WAITING 0.0 0.000 0:0.000 false true
2 Reference Handler system 10 WAITING 0 0:0 false true
204 pool-8-thread-1 system 5 WAITING 0 0:0 false false
``` ```

Binary file not shown.

Before

Width:  |  Height:  |  Size: 976 KiB

After

Width:  |  Height:  |  Size: 791 KiB

@ -1,6 +1,6 @@
var DOCUMENTATION_OPTIONS = { var DOCUMENTATION_OPTIONS = {
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'), URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
VERSION: '3.4.1', VERSION: '3.4.2',
LANGUAGE: 'en', LANGUAGE: 'en',
COLLAPSE_INDEX: false, COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html', FILE_SUFFIX: '.html',

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Advanced Usage &mdash; Arthas 3.4.1 documentation</title> <title>Advanced Usage &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fundamental Fields in Expressions &mdash; Arthas 3.4.1 documentation</title> <title>Fundamental Fields in Expressions &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Start as a Java Agent &mdash; Arthas 3.4.1 documentation</title> <title>Start as a Java Agent &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Arthas Properties &mdash; Arthas 3.4.1 documentation</title> <title>Arthas Properties &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Arthas Async Jobs &mdash; Arthas 3.4.1 documentation</title> <title>Arthas Async Jobs &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Batch Processing &mdash; Arthas 3.4.1 documentation</title> <title>Batch Processing &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>cat &mdash; Arthas 3.4.1 documentation</title> <title>cat &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>classloader &mdash; Arthas 3.4.1 documentation</title> <title>classloader &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>All Commands &mdash; Arthas 3.4.1 documentation</title> <title>All Commands &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contact Us &mdash; Arthas 3.4.1 documentation</title> <title>Contact Us &mdash; Arthas 3.4.2 documentation</title>
@ -72,7 +72,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>dashboard &mdash; Arthas 3.4.1 documentation</title> <title>dashboard &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>
@ -108,7 +108,10 @@
<li class="toctree-l2 current"><a class="current reference internal" href="#">dashboard</a><ul> <li class="toctree-l2 current"><a class="current reference internal" href="#">dashboard</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#options">Options</a></li> <li class="toctree-l3"><a class="reference internal" href="#options">Options</a></li>
<li class="toctree-l3"><a class="reference internal" href="#usage">Usage</a></li> <li class="toctree-l3"><a class="reference internal" href="#usage">Usage</a></li>
<li class="toctree-l3"><a class="reference internal" href="#notes-on-column-headers">Notes on column headers</a></li> <li class="toctree-l3"><a class="reference internal" href="#notes-on-column-headers">Notes on column headers</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#jvm-internal-threads">JVM internal threads</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#screenshot">Screenshot</a></li> <li class="toctree-l3"><a class="reference internal" href="#screenshot">Screenshot</a></li>
</ul> </ul>
</li> </li>
@ -254,39 +257,37 @@
<div class="section" id="usage"> <div class="section" id="usage">
<h2>Usage<a class="headerlink" href="#usage" title="Permalink to this headline"></a></h2> <h2>Usage<a class="headerlink" href="#usage" title="Permalink to this headline"></a></h2>
<div class="highlight-default notranslate"><pre class="literal-block">$ dashboard <div class="highlight-default notranslate"><pre class="literal-block">$ dashboard
ID NAME GROUP PRIORITY STATE %CPU TIME INTERRUPTED DAEMON ID NAME GROUP PRIORITY STATE %CPU DELTA_TIME TIME INTERRUPTE DAEMON
889 RMI TCP Connection(15)-30.10.166. RMI Runtime 9 RUNNABLE 48 0:5 false true -1 C2 CompilerThread0 - -1 - 1.55 0.077 0:8.684 false true
1077 Timer-for-arthas-dashboard-0 system 9 RUNNABLE 24 0:0 false true 53 Timer-for-arthas-dashboard-07b system 5 RUNNABLE 0.08 0.004 0:0.004 false true
1074 as-selector-daemon system 9 RUNNABLE 12 0:0 false true 22 scheduling-1 main 5 TIMED_WAI 0.06 0.003 0:0.287 false false
284 JMX server connection timeout 284 RMI Runtime 9 TIMED_WAITI 8 0:3 false true -1 C1 CompilerThread0 - -1 - 0.06 0.003 0:2.171 false true
16 Timer-1 main 5 TIMED_WAITI 5 0:9 false true -1 VM Periodic Task Thread - -1 - 0.03 0.001 0:0.092 false true
47 Pandora pandora-qos-reporter Pool main 5 TIMED_WAITI 0 0:0 false true 49 arthas-NettyHttpTelnetBootstra system 5 RUNNABLE 0.02 0.001 0:0.156 false true
48 JmonitorClient-CheckThread Pool [ main 5 TIMED_WAITI 0 0:0 false true 16 Catalina-utility-1 main 1 TIMED_WAI 0.0 0.000 0:0.029 false false
49 JmonitorClient-HeartBeat Pool [Th main 5 TIMED_WAITI 0 0:0 false true -1 G1 Young RemSet Sampling - -1 - 0.0 0.000 0:0.019 false true
50 JmonitorClient-ReaderThread Pool main 5 TIMED_WAITI 0 0:0 false true 17 Catalina-utility-2 main 1 WAITING 0.0 0.000 0:0.025 false false
957 RMI TCP Connection(16)-30.10.166. RMI Runtime 9 RUNNABLE 0 0:2 false true 34 http-nio-8080-ClientPoller main 5 RUNNABLE 0.0 0.000 0:0.016 false true
51 JmonitorClient-WriterThread Pool main 5 TIMED_WAITI 0 0:0 false true 23 http-nio-8080-BlockPoller main 5 RUNNABLE 0.0 0.000 0:0.011 false true
52 ContainerBackgroundProcessor[Stan main 5 TIMED_WAITI 0 0:0 false true -1 VM Thread - -1 - 0.0 0.000 0:0.032 false true
53 http-bio-8080-Acceptor-0 main 5 RUNNABLE 0 0:2 false true -1 Service Thread - -1 - 0.0 0.000 0:0.006 false true
54 http-bio-8080-AsyncTimeout main 5 TIMED_WAITI 0 0:0 false true -1 GC Thread#5 - -1 - 0.0 0.000 0:0.043 false true
11 GC Daemon system 2 TIMED_WAITI 0 0:0 false true
Memory used total max usage GC Memory used total max usage GC
heap 59M 223M 1820M 3.26% gc.ps_scavenge.count 118 heap 36M 70M 4096M 0.90% gc.g1_young_generation.count 12
ps_eden_space 14M 114M 668M 2.11% gc.ps_scavenge.time(ms) 1890 g1_eden_space 6M 18M -1 33.33% 86
ps_survivor_space 6M 6M 6M 96.08% gc.ps_marksweep.count 5 g1_old_gen 30M 50M 4096M 0.74% gc.g1_old_generation.count 0
ps_old_gen 39M 103M 1365M 2.86% gc.ps_marksweep.time(ms) 1140 g1_survivor_space 491K 2048K -1 24.01% gc.g1_old_generation.time(ms) 0
nonheap 234M 240M 0M 97.46% nonheap 66M 69M -1 96.56%
code_cache 46M 47M 240M 19.49% codeheap_&#x27;non-nmethods&#x27; 1M 2M 5M 22.39%
metaspace 167M 172M 0M 97.36% metaspace 46M 47M -1 98.01%
Runtime Tomcat Runtime
os.name Mac OS X connector http-bio-8080 os.name Mac OS X
os.version 10.10.5 QPS 0.00 os.version 10.15.4
java.version 1.8.0_60 RT(ms) 1.13 java.version 15
java.home error/s 0.00 java.home /Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home
received/s 0B systemload.average 10.68
systemload.average 3.44 sent/s 0B processors 8
processors 4 threadpool http-bio-8080 uptime 272s</pre>
uptime 16020s busy 0</pre>
</div> </div>
</div> </div>
<div class="section" id="notes-on-column-headers"> <div class="section" id="notes-on-column-headers">
@ -297,11 +298,31 @@ uptime 16020s busy
<li><p>GROUP: thread group name</p></li> <li><p>GROUP: thread group name</p></li>
<li><p>PRIORITY: thread priority, ranged from 1 to 10. The greater number, the higher priority</p></li> <li><p>PRIORITY: thread priority, ranged from 1 to 10. The greater number, the higher priority</p></li>
<li><p>STATE: thread state</p></li> <li><p>STATE: thread state</p></li>
<li><p>CPU%: the ratio of CPU usage for the thread, sampled every 100ms</p></li> <li><p>CPU%: the ratio of CPU usage for the thread. For example, the sampling interval is 1000ms, and the incremental cpu time
<li><p>TIME: total running time in <code class="docutils literal notranslate"><span class="pre">minute:second</span></code> format</p></li> of a thread is 100ms, then the cpu usage rate=100/1000=10%</p></li>
<li><p>DELTA_TIME: incremental CPU time of thread running after the last sampling in <code class="docutils literal notranslate"><span class="pre">second</span></code> format</p></li>
<li><p>TIME: total CPU time of the thread in <code class="docutils literal notranslate"><span class="pre">minute:second</span></code> format</p></li>
<li><p>INTERRUPTED: the thread interruption state</p></li> <li><p>INTERRUPTED: the thread interruption state</p></li>
<li><p>DAEMON: daemon thread or not</p></li> <li><p>DAEMON: daemon thread or not</p></li>
</ul> </ul>
<div class="section" id="jvm-internal-threads">
<h3>JVM internal threads<a class="headerlink" href="#jvm-internal-threads" title="Permalink to this headline"></a></h3>
<p>After Java 8, it is supported to obtain the CPU time of JVM internal threads. These threads only have the name and CPU time,
without ID and status information (display ID is -1).</p>
<p>JVM activities can be observed through internal threads, such as GC, JIT compilation, etc., to perceive the overall status of JVM.</p>
<ul class="simple">
<li><p>When the JVM heap/metaspace space is insufficient or OOM, it can be seen that the CPU usage of the GC threads is
significantly higher than other threads.</p></li>
<li><p>After executing commands such as <code class="docutils literal notranslate"><span class="pre">trace/watch/tt/redefine</span></code>, you can see that JIT threads activities become more frequent.
Because the JIT compilation data related to this class is cleared when the JVM hot update the class bytecode, it needs to be recompiled.</p></li>
</ul>
<p>JVM internal threads include the following:</p>
<ul class="simple">
<li><p>JIT compilation thread: such as <code class="docutils literal notranslate"><span class="pre">C1</span> <span class="pre">CompilerThread0</span></code>, <code class="docutils literal notranslate"><span class="pre">C2</span> <span class="pre">CompilerThread0</span></code></p></li>
<li><p>GC thread: such as <code class="docutils literal notranslate"><span class="pre">GC</span> <span class="pre">Thread0</span></code>, <code class="docutils literal notranslate"><span class="pre">G1</span> <span class="pre">Young</span> <span class="pre">RemSet</span> <span class="pre">Sampling</span></code></p></li>
<li><p>Other internal threads: such as<code class="docutils literal notranslate"><span class="pre">VM</span> <span class="pre">Periodic</span> <span class="pre">Task</span> <span class="pre">Thread</span></code>, <code class="docutils literal notranslate"><span class="pre">VM</span> <span class="pre">Thread</span></code>, <code class="docutils literal notranslate"><span class="pre">Service</span> <span class="pre">Thread</span></code></p></li>
</ul>
</div>
</div> </div>
<div class="section" id="screenshot"> <div class="section" id="screenshot">
<h2>Screenshot<a class="headerlink" href="#screenshot" title="Permalink to this headline"></a></h2> <h2>Screenshot<a class="headerlink" href="#screenshot" title="Permalink to this headline"></a></h2>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Docker &mdash; Arthas 3.4.1 documentation</title> <title>Docker &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Download &mdash; Arthas 3.4.1 documentation</title> <title>Download &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>dump &mdash; Arthas 3.4.1 documentation</title> <title>dump &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>echo &mdash; Arthas 3.4.1 documentation</title> <title>echo &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -9,7 +9,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Index &mdash; Arthas 3.4.1 documentation</title> <title>Index &mdash; Arthas 3.4.2 documentation</title>
@ -72,7 +72,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>getstatic &mdash; Arthas 3.4.1 documentation</title> <title>getstatic &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>grep &mdash; Arthas 3.4.1 documentation</title> <title>grep &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>groovy &mdash; Arthas 3.4.1 documentation</title> <title>groovy &mdash; Arthas 3.4.2 documentation</title>
@ -71,7 +71,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>heapdump &mdash; Arthas 3.4.1 documentation</title> <title>heapdump &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Http API &mdash; Arthas 3.4.1 documentation</title> <title>Http API &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>IDEA Plugin &mdash; Arthas 3.4.1 documentation</title> <title>IDEA Plugin &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Arthas Documentation &mdash; Arthas 3.4.1 documentation</title> <title>Arthas Documentation &mdash; Arthas 3.4.2 documentation</title>
@ -72,7 +72,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Install Arthas &mdash; Arthas 3.4.1 documentation</title> <title>Install Arthas &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>jad &mdash; Arthas 3.4.1 documentation</title> <title>jad &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>jvm &mdash; Arthas 3.4.1 documentation</title> <title>jvm &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Arthas Console Keymap &mdash; Arthas 3.4.1 documentation</title> <title>Arthas Console Keymap &mdash; Arthas 3.4.2 documentation</title>
@ -71,7 +71,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>logger &mdash; Arthas 3.4.1 documentation</title> <title>logger &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Manually Install Arthas &mdash; Arthas 3.4.1 documentation</title> <title>Manually Install Arthas &mdash; Arthas 3.4.2 documentation</title>
@ -71,7 +71,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>mbean &mdash; Arthas 3.4.1 documentation</title> <title>mbean &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>mc &mdash; Arthas 3.4.1 documentation</title> <title>mc &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>monitor &mdash; Arthas 3.4.1 documentation</title> <title>monitor &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

Binary file not shown.

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ognl &mdash; Arthas 3.4.1 documentation</title> <title>ognl &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>options &mdash; Arthas 3.4.1 documentation</title> <title>options &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>perfcounter &mdash; Arthas 3.4.1 documentation</title> <title>perfcounter &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>profiler &mdash; Arthas 3.4.1 documentation</title> <title>profiler &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>pwd &mdash; Arthas 3.4.1 documentation</title> <title>pwd &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Quick Start &mdash; Arthas 3.4.1 documentation</title> <title>Quick Start &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>redefine &mdash; Arthas 3.4.1 documentation</title> <title>redefine &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Release Notes &mdash; Arthas 3.4.1 documentation</title> <title>Release Notes &mdash; Arthas 3.4.2 documentation</title>
@ -71,7 +71,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>reset &mdash; Arthas 3.4.1 documentation</title> <title>reset &mdash; Arthas 3.4.2 documentation</title>
@ -71,7 +71,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Log command outputs &mdash; Arthas 3.4.1 documentation</title> <title>Log command outputs &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>sc &mdash; Arthas 3.4.1 documentation</title> <title>sc &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Search &mdash; Arthas 3.4.1 documentation</title> <title>Search &mdash; Arthas 3.4.2 documentation</title>
@ -72,7 +72,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

File diff suppressed because one or more lines are too long

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>sm &mdash; Arthas 3.4.1 documentation</title> <title>sm &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Arthas Spring Boot Starter &mdash; Arthas 3.4.1 documentation</title> <title>Arthas Spring Boot Starter &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>stack &mdash; Arthas 3.4.1 documentation</title> <title>stack &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Start Arthas &mdash; Arthas 3.4.1 documentation</title> <title>Start Arthas &mdash; Arthas 3.4.2 documentation</title>
@ -71,7 +71,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>sysenv &mdash; Arthas 3.4.1 documentation</title> <title>sysenv &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>sysprop &mdash; Arthas 3.4.1 documentation</title> <title>sysprop &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>tee &mdash; Arthas 3.4.1 documentation</title> <title>tee &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>thread &mdash; Arthas 3.4.1 documentation</title> <title>thread &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>
@ -108,9 +108,11 @@
<li class="toctree-l2"><a class="reference internal" href="dashboard.html">dashboard</a></li> <li class="toctree-l2"><a class="reference internal" href="dashboard.html">dashboard</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">thread</a><ul> <li class="toctree-l2 current"><a class="current reference internal" href="#">thread</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#parameters">Parameters</a></li> <li class="toctree-l3"><a class="reference internal" href="#parameters">Parameters</a></li>
<li class="toctree-l3"><a class="reference internal" href="#how-the-cpu-ratios-are-calculated">How the CPU ratios are calculated?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#usage">Usage</a><ul> <li class="toctree-l3"><a class="reference internal" href="#usage">Usage</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#list-the-top-n-busiest-threads-with-detailed-stack-trace">List the top n busiest threads with detailed stack trace</a></li> <li class="toctree-l4"><a class="reference internal" href="#list-the-top-n-busiest-threads-with-detailed-stack-trace">List the top n busiest threads with detailed stack trace</a></li>
<li class="toctree-l4"><a class="reference internal" href="#list-all-threads-info-when-no-options-provided">List all threads info when no options provided</a></li> <li class="toctree-l4"><a class="reference internal" href="#list-first-page-threads-info-when-no-options-provided">List first page threads info when no options provided</a></li>
<li class="toctree-l4"><a class="reference internal" href="#thread-all-show-all-matching-threads">thread all, show all matching threads</a></li>
<li class="toctree-l4"><a class="reference internal" href="#thread-id-show-the-running-stack-for-the-target-thread">thread id, show the running stack for the target thread</a></li> <li class="toctree-l4"><a class="reference internal" href="#thread-id-show-the-running-stack-for-the-target-thread">thread id, show the running stack for the target thread</a></li>
<li class="toctree-l4"><a class="reference internal" href="#thread-b-locate-the-thread-bocking-the-others">thread -b, locate the thread bocking the others</a></li> <li class="toctree-l4"><a class="reference internal" href="#thread-b-locate-the-thread-bocking-the-others">thread -b, locate the thread bocking the others</a></li>
<li class="toctree-l4"><a class="reference internal" href="#thread-i-specify-the-sampling-interval">thread -i, specify the sampling interval</a></li> <li class="toctree-l4"><a class="reference internal" href="#thread-i-specify-the-sampling-interval">thread -i, specify the sampling interval</a></li>
@ -262,12 +264,31 @@
<td align="right">[i <code>&lt;value&gt;</code>]</td> <td align="right">[i <code>&lt;value&gt;</code>]</td>
<td align="left">specify the interval to collect data to compute CPU ratios (ms)</td> <td align="left">specify the interval to collect data to compute CPU ratios (ms)</td>
</tr> </tr>
<tr>
<td align="right">[--all]</td>
<td align="left">Show all matching threads</td>
</tr>
</tbody> </tbody>
</table><blockquote> </table></div>
<div><p>How the CPU ratios are calculated? <br/><br/> <div class="section" id="how-the-cpu-ratios-are-calculated">
CPU ratio for a given thread is the CPU time it takes divided by the total CPU time within a specified interval period. It is calculated in the following way: sample CPU times for all the thread by calling <code class="docutils literal notranslate"><span class="pre">java.lang.management.ThreadMXBean#getThreadCpuTime</span></code> first, then sleep for a period (the default value is 100ms, which can be specified by <code class="docutils literal notranslate"><span class="pre">-i</span></code>), then sample CPU times again. By this, we can get the time cost for this period for each thread, then come up with the ratio. <br/><br/> <h2>How the CPU ratios are calculated?<a class="headerlink" href="#how-the-cpu-ratios-are-calculated" title="Permalink to this headline"></a></h2>
Note: this operation consumes CPU time too (<code class="docutils literal notranslate"><span class="pre">getThreadCpuTime</span></code> is time-consuming), therefore it is possible to observe Arthass thread appears in the list. To avoid this, try to increase sample interval, for example: 5000 ms.<br/><br/> <p>The cpu ratios here is similar to the thread <code class="docutils literal notranslate"><span class="pre">%CPU</span></code> of the linux command <code class="docutils literal notranslate"><span class="pre">top</span> <span class="pre">-H</span> <span class="pre">-p</span> <span class="pre">&lt;pid&gt;</span></code>. During a sampling interval,
If youd like to check the CPU ratios from the very beginning of the Java process, <a class="reference external" href="https://github.com/oldratlee/useful-scripts/blob/master/docs/java.md#-show-busy-java-threads">show-busy-java-threads</a> can come to help.</p> the ratio of the incremental cpu time of each thread in the current JVM to the sampling interval time.</p>
<blockquote>
<div><p>Working principle description:</p>
</div></blockquote>
<ul class="simple">
<li><p>Do the first sampling, get the CPU time of all threads ( by calling <code class="docutils literal notranslate"><span class="pre">java.lang.management.ThreadMXBean#getThreadCpuTime()</span></code> and
<code class="docutils literal notranslate"><span class="pre">sun.management.HotspotThreadMBean.getInternalThreadCpuTimes()</span></code> )</p></li>
<li><p>Sleep and wait for an interval (the default is 200ms, the interval can be specified by <code class="docutils literal notranslate"><span class="pre">-i</span></code>)</p></li>
<li><p>Do the second sampling, get the CPU time of all threads, compare the two sampling data, and calculate the incremental CPU time of each thread</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">Thread</span> <span class="pre">CPU</span> <span class="pre">usage</span> <span class="pre">ratio</span></code> = <code class="docutils literal notranslate"><span class="pre">Thread</span> <span class="pre">increment</span> <span class="pre">CPU</span> <span class="pre">time</span></code> / <code class="docutils literal notranslate"><span class="pre">Sampling</span> <span class="pre">interval</span> <span class="pre">time</span></code> * 100%</p></li>
</ul>
<blockquote>
<div><p>Note: this operation consumes CPU time too (<code class="docutils literal notranslate"><span class="pre">getThreadCpuTime</span></code> is time-consuming), therefore it is possible to observe Arthass thread appears in the list. To avoid this, try to increase sample interval, for example: 5000 ms.<br/></p>
</div></blockquote>
<blockquote>
<div><p>Another way to view the thread cpu usage of the Java process, <a class="reference external" href="https://github.com/oldratlee/useful-scripts/blob/master/docs/java.md#-show-busy-java-threads">show-busy-java-threads</a> can come to help.</p>
</div></blockquote> </div></blockquote>
</div> </div>
<div class="section" id="usage"> <div class="section" id="usage">
@ -275,54 +296,66 @@ If youd like to check the CPU ratios from the very beginning of the Java proc
<div class="section" id="list-the-top-n-busiest-threads-with-detailed-stack-trace"> <div class="section" id="list-the-top-n-busiest-threads-with-detailed-stack-trace">
<h3>List the top n busiest threads with detailed stack trace<a class="headerlink" href="#list-the-top-n-busiest-threads-with-detailed-stack-trace" title="Permalink to this headline"></a></h3> <h3>List the top n busiest threads with detailed stack trace<a class="headerlink" href="#list-the-top-n-busiest-threads-with-detailed-stack-trace" title="Permalink to this headline"></a></h3>
<div class="highlight-shell notranslate"><div class="highlight hljs"><pre class="shell">$ thread -n 3 <div class="highlight-shell notranslate"><div class="highlight hljs"><pre class="shell">$ thread -n 3
&quot;as-command-execute-daemon&quot; Id=29 cpuUsage=75% RUNNABLE &quot;C1 CompilerThread0&quot; [Internal] cpuUsage=1.63% deltaTime=3ms time=1170ms
at sun.management.ThreadImpl.dumpThreads0(Native Method)
at sun.management.ThreadImpl.getThreadInfo(ThreadImpl.java:440) &quot;arthas-command-execute&quot; Id=23 cpuUsage=0.11% deltaTime=0ms time=401ms RUNNABLE
at com.taobao.arthas.core.command.monitor200.ThreadCommand$1.action(ThreadCommand.java:58) at java.management@11.0.7/sun.management.ThreadImpl.dumpThreads0(Native Method)
at com.taobao.arthas.core.command.handler.AbstractCommandHandler.execute(AbstractCommandHandler.java:238) at java.management@11.0.7/sun.management.ThreadImpl.getThreadInfo(ThreadImpl.java:466)
at com.taobao.arthas.core.command.handler.DefaultCommandHandler.handleCommand(DefaultCommandHandler.java:67) at com.taobao.arthas.core.command.monitor200.ThreadCommand.processTopBusyThreads(ThreadCommand.java:199)
at com.taobao.arthas.core.server.ArthasServer$4.run(ArthasServer.java:276) at com.taobao.arthas.core.command.monitor200.ThreadCommand.process(ThreadCommand.java:122)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl.process(AnnotatedCommandImpl.java:82)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl.access$100(AnnotatedCommandImpl.java:18)
at java.lang.Thread.run(Thread.java:745) at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl$ProcessHandler.handle(AnnotatedCommandImpl.java:111)
at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl$ProcessHandler.handle(AnnotatedCommandImpl.java:108)
Number of locked synchronizers = 1 at com.taobao.arthas.core.shell.system.impl.ProcessImpl$CommandProcessTask.run(ProcessImpl.java:385)
- java.util.concurrent.ThreadPoolExecutor$Worker@6cd0b6f8 at java.base@11.0.7/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base@11.0.7/java.util.concurrent.FutureTask.run(FutureTask.java:264)
&quot;as-session-expire-daemon&quot; Id=25 cpuUsage=24% TIMED_WAITING at java.base@11.0.7/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
at java.lang.Thread.sleep(Native Method) at java.base@11.0.7/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at com.taobao.arthas.core.server.DefaultSessionManager$2.run(DefaultSessionManager.java:85) at java.base@11.0.7/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base@11.0.7/java.lang.Thread.run(Thread.java:834)
&quot;Reference Handler&quot; Id=2 cpuUsage=0% WAITING on java.lang.ref.Reference$Lock@69ba0f27
at java.lang.Object.wait(Native Method) &quot;VM Periodic Task Thread&quot; [Internal] cpuUsage=0.07% deltaTime=0ms time=584ms</pre></div>
- waiting on java.lang.ref.Reference$Lock@69ba0f27
at java.lang.Object.wait(Object.java:503)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)</pre></div>
</div> </div>
<ul class="simple">
<li><p>Without thread ID, including <code class="docutils literal notranslate"><span class="pre">[Internal]</span></code> means JVM internal thread, refer to the introduction of <a class="reference internal" href="dashboard.html"><span class="doc">dashboard</span></a> command.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">cpuUsage</span></code> is the CPU usage of the thread during the sampling interval, consistent with the data of the <a class="reference internal" href="dashboard.html"><span class="doc">dashboard</span></a> command.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">deltaTime</span></code> is the incremental CPU time of the thread during the sampling interval. If it is less than 1ms, it will be rounded and displayed as 0ms.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">time</span></code> The total CPU time of thread.</p></li>
</ul>
<p><strong>Note:</strong> The thread stack is acquired at the end of the second sampling, which does not indicate that the thread is
processing the same task during the sampling interval. It is recommended that the interval time should not be too long.
The larger the interval time, the more inaccurate.</p>
<p>You can try to specify different intervals according to the specific situation and observe the output results.</p>
</div> </div>
<div class="section" id="list-all-threads-info-when-no-options-provided"> <div class="section" id="list-first-page-threads-info-when-no-options-provided">
<h3>List all threads info when no options provided<a class="headerlink" href="#list-all-threads-info-when-no-options-provided" title="Permalink to this headline"></a></h3> <h3>List first page threads info when no options provided<a class="headerlink" href="#list-first-page-threads-info-when-no-options-provided" title="Permalink to this headline"></a></h3>
<p>By default, they are arranged in descending order of CPU increment time, and only the first page of data is displayed.</p>
<div class="highlight-shell notranslate"><div class="highlight hljs"><pre class="shell">$ thread <div class="highlight-shell notranslate"><div class="highlight hljs"><pre class="shell">$ thread
Threads Total: 16, NEW: 0, RUNNABLE: 7, BLOCKED: 0, WAITING: 5, TIMED_WAITING: 4, TERMINATED: 0 Threads Total: 33, NEW: 0, RUNNABLE: 9, BLOCKED: 0, WAITING: 3, TIMED_WAITING: 4, TERMINATED: 0, Internal threads: 17
ID NAME GROUP PRIORITY STATE %CPU TIME INTERRUPTE DAEMON ID NAME GROUP PRIORITY STATE %CPU DELTA_TIME TIME INTERRUPT DAEMON
30 as-command-execute-daemon system 9 RUNNABLE 72 0:0 false true -1 C2 CompilerThread0 - -1 - 5.06 0.010 0:0.973 false true
23 as-session-expire-daemon system 9 TIMED_WAIT 27 0:0 false true -1 C1 CompilerThread0 - -1 - 0.95 0.001 0:0.603 false true
22 Attach Listener system 9 RUNNABLE 0 0:0 false true 23 arthas-command-execute system 5 RUNNABLE 0.17 0.000 0:0.226 false true
11 pool-2-thread-1 main 5 TIMED_WAIT 0 0:0 false false -1 VM Periodic Task Thread - -1 - 0.05 0.000 0:0.094 false true
12 Thread-2 main 5 RUNNABLE 0 0:0 false true -1 Sweeper thread - -1 - 0.04 0.000 0:0.011 false true
13 pool-3-thread-1 main 5 TIMED_WAIT 0 0:0 false false -1 G1 Young RemSet Sampling - -1 - 0.02 0.000 0:0.025 false true
25 as-selector-daemon system 9 RUNNABLE 0 0:0 false true 12 Attach Listener system 9 RUNNABLE 0.0 0.000 0:0.022 false true
14 Thread-3 main 5 TIMED_WAIT 0 0:0 false false 11 Common-Cleaner InnocuousThrea 8 TIMED_WAI 0.0 0.000 0:0.000 false true
26 pool-5-thread-1 system 5 WAITING 0 0:0 false false 3 Finalizer system 8 WAITING 0.0 0.000 0:0.000 false true
15 Thread-4 main 5 RUNNABLE 0 0:0 false false 2 Reference Handler system 10 RUNNABLE 0.0 0.000 0:0.000 false true
1 main main 5 WAITING 0 0:2 false false 4 Signal Dispatcher system 9 RUNNABLE 0.0 0.000 0:0.000 false true
2 Reference Handler system 10 WAITING 0 0:0 false true 15 arthas-NettyHttpTelnetBootstra system 5 RUNNABLE 0.0 0.000 0:0.029 false true
3 Finalizer system 8 WAITING 0 0:0 false true 22 arthas-NettyHttpTelnetBootstra system 5 RUNNABLE 0.0 0.000 0:0.196 false true
4 Signal Dispatcher system 9 RUNNABLE 0 0:0 false true 24 arthas-NettyHttpTelnetBootstra system 5 RUNNABLE 0.0 0.000 0:0.038 false true
20 NonBlockingInputStreamThread main 5 WAITING 0 0:0 false true 16 arthas-NettyWebsocketTtyBootst system 5 RUNNABLE 0.0 0.000 0:0.001 false true
21 Thread-8 main 5 RUNNABLE 0 0:0 false true</pre></div> 17 arthas-NettyWebsocketTtyBootst system 5 RUNNABLE 0.0 0.000 0:0.001 false true</pre></div>
</div> </div>
</div> </div>
<div class="section" id="thread-all-show-all-matching-threads">
<h3>thread all, show all matching threads<a class="headerlink" href="#thread-all-show-all-matching-threads" title="Permalink to this headline"></a></h3>
<p>Display all matching threads. Sometimes it is necessary to obtain all the thread data of the JVM for analysis.</p>
</div>
<div class="section" id="thread-id-show-the-running-stack-for-the-target-thread"> <div class="section" id="thread-id-show-the-running-stack-for-the-target-thread">
<h3>thread id, show the running stack for the target thread<a class="headerlink" href="#thread-id-show-the-running-stack-for-the-target-thread" title="Permalink to this headline"></a></h3> <h3>thread id, show the running stack for the target thread<a class="headerlink" href="#thread-id-show-the-running-stack-for-the-target-thread" title="Permalink to this headline"></a></h3>
<div class="highlight-shell notranslate"><div class="highlight hljs"><pre class="shell">$ thread 1 <div class="highlight-shell notranslate"><div class="highlight hljs"><pre class="shell">$ thread 1
@ -382,6 +415,10 @@ ID NAME GROUP PRIORITY STA
</div> </div>
<div class="section" id="thread-i-specify-the-sampling-interval"> <div class="section" id="thread-i-specify-the-sampling-interval">
<h3>thread -i, specify the sampling interval<a class="headerlink" href="#thread-i-specify-the-sampling-interval" title="Permalink to this headline"></a></h3> <h3>thread -i, specify the sampling interval<a class="headerlink" href="#thread-i-specify-the-sampling-interval" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">thread</span> <span class="pre">-i</span> <span class="pre">1000</span></code>: Count the thread cpu time of the last 1000ms.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">thread</span> <span class="pre">-n</span> <span class="pre">3</span> <span class="pre">-i</span> <span class="pre">1000</span></code>: List the 3 busiest thread stacks in 1000ms</p></li>
</ul>
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">$ thread -n 3 -i 1000 <div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">$ thread -n 3 -i 1000
&quot;as-command-execute-daemon&quot; Id=4759 cpuUsage=23% RUNNABLE &quot;as-command-execute-daemon&quot; Id=4759 cpuUsage=23% RUNNABLE
at sun.management.ThreadImpl.dumpThreads0(Native Method) at sun.management.ThreadImpl.dumpThreads0(Native Method)
@ -405,13 +442,11 @@ ID NAME GROUP PRIORITY STA
<div class="section" id="thread-state-view-the-special-state-theads"> <div class="section" id="thread-state-view-the-special-state-theads">
<h3>thread state , view the special state theads<a class="headerlink" href="#thread-state-view-the-special-state-theads" title="Permalink to this headline"></a></h3> <h3>thread state , view the special state theads<a class="headerlink" href="#thread-state-view-the-special-state-theads" title="Permalink to this headline"></a></h3>
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">[arthas@28114]$ thread --state WAITING <div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">[arthas@28114]$ thread --state WAITING
Threads Total: 15, NEW: 0, RUNNABLE: 7, BLOCKED: 0, WAITING: 5, TIMED_WAITING: 3, TERMINATED: 0 Threads Total: 16, NEW: 0, RUNNABLE: 9, BLOCKED: 0, WAITING: 3, TIMED_WAITING: 4, TERMINATED: 0
ID NAME GROUP PRIORITY STATE %CPU TIME INTERRU DAEMON ID NAME GROUP PRIORITY STATE %CPU DELTA_TIME TIME INTERRUPTE DAEMON
198 AsyncAppender-Worker-arth system 9 WAITING 0 0:0 false true 3 Finalizer system 8 WAITING 0.0 0.000 0:0.000 false true
3 Finalizer system 8 WAITING 0 0:0 false true 20 arthas-UserStat system 9 WAITING 0.0 0.000 0:0.001 false true
14 RMI Scheduler(0) system 9 WAITING 0 0:0 false true 14 arthas-timer system 9 WAITING 0.0 0.000 0:0.000 false true</pre></div>
2 Reference Handler system 10 WAITING 0 0:0 false true
204 pool-8-thread-1 system 5 WAITING 0 0:0 false false</pre></div>
</div> </div>
</div> </div>
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>trace &mdash; Arthas 3.4.1 documentation</title> <title>trace &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>tt &mdash; Arthas 3.4.1 documentation</title> <title>tt &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>vmoption &mdash; Arthas 3.4.1 documentation</title> <title>vmoption &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>watch &mdash; Arthas 3.4.1 documentation</title> <title>watch &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Web Console &mdash; Arthas 3.4.1 documentation</title> <title>Web Console &mdash; Arthas 3.4.2 documentation</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -9,7 +9,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>索引 &mdash; Arthas 3.4.1 文档</title> <title>索引 &mdash; Arthas 3.4.2 文档</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>getstatic &mdash; Arthas 3.4.1 文档</title> <title>getstatic &mdash; Arthas 3.4.2 文档</title>
@ -74,7 +74,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>grep &mdash; Arthas 3.4.1 文档</title> <title>grep &mdash; Arthas 3.4.2 文档</title>
@ -74,7 +74,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>groovy &mdash; Arthas 3.4.1 文档</title> <title>groovy &mdash; Arthas 3.4.2 文档</title>
@ -72,7 +72,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>heapdump &mdash; Arthas 3.4.1 文档</title> <title>heapdump &mdash; Arthas 3.4.2 文档</title>
@ -74,7 +74,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Http API &mdash; Arthas 3.4.1 文档</title> <title>Http API &mdash; Arthas 3.4.2 文档</title>
@ -74,7 +74,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>IDEA Plugin &mdash; Arthas 3.4.1 文档</title> <title>IDEA Plugin &mdash; Arthas 3.4.2 文档</title>
@ -74,7 +74,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Arthas 用户文档 &mdash; Arthas 3.4.1 文档</title> <title>Arthas 用户文档 &mdash; Arthas 3.4.2 文档</title>
@ -73,7 +73,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Arthas Install &mdash; Arthas 3.4.1 文档</title> <title>Arthas Install &mdash; Arthas 3.4.2 文档</title>
@ -74,7 +74,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>jad &mdash; Arthas 3.4.1 文档</title> <title>jad &mdash; Arthas 3.4.2 文档</title>
@ -74,7 +74,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>jvm &mdash; Arthas 3.4.1 文档</title> <title>jvm &mdash; Arthas 3.4.2 文档</title>
@ -74,7 +74,7 @@
<div class="version"> <div class="version">
3.4.1 3.4.2
</div> </div>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save