一个底层调试工具,比Btrace来的更简单。目前好像是淘宝的同学在维护。
下载
git clone https://github.com/oldmanpushcart/greys-anatomy.git
编译
cd ~/bin && sh ./greys-packages.sh
安装
拷贝target目录下生成的zip文件,并解压;解压后执行 install-local.sh
这个脚本即可安装。
运行
执行sh greys.sh ${pid}
进行程序
trace -n 2 com.netease.urs.CookieDecoder requestDecode '#cost>500'
-n 2 :代表只打印2次就退出(防止刷屏,影响性能);
com.netease.urs.CookieDecoder :监听的类名
requestDecode :监听的方法名
‘#cost>500’ : 打印条件为 耗时超过 500ms
stack org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FSParentQueue assignContainer
tt -t org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FSParentQueue assignContainer -n 5
记录10次方法的执行耗时,参数等信息
Press Ctrl+D to abort.
Affect(class-cnt:1 , method-cnt:1) cost in 102 ms.
+———-+————+———————-+————+———-+———-+—————–+——————————–+-+
| INDEX | PROCESS-ID | TIMESTAMP | COST(ms) | IS-RET | IS-EXP | OBJECT | CLASS | |
+———-+————+———————-+————+———-+———-+—————–+——————————–+-+
| 1001 | 1001 | 2018-07-17 18:39:12 | 1 | true | false | 0x55b1388a | FSParentQueue | |
+———-+————+———————-+————+———-+———-+—————–+——————————–+-+
| 1002 | 1002 | 2018-07-17 18:39:13 | 1 | true | false | 0x55b1388a | FSParentQueue | |
+———-+————+———————-+————+———-+———-+—————–+——————————–+-+
| 1003 | 1003 | 2018-07-17 18:39:13 | 0 | true | false | 0x55b1388a | FSParentQueue | |
+———-+————+———————-+————+———-+———-+—————–+——————————–+-+
| 1004 | 1004 | 2018-07-17 18:39:13 | 0 | true | false | 0x55b1388a | FSParentQueue | |
+———-+————+———————-+————+———-+———-+—————–+——————————–+-+
| 1005 | 1005 | 2018-07-17 18:39:13 | 0 | true | false | 0x55b1388a | FSParentQueue | |
+———-+————+———————-+————+———-+———-+—————–+——————————–+-+
tt -i 1001
查看具体方法调用信息
+—————–+——————————————————————————————————————————————————–+
| INDEX | 1001 |
+—————–+——————————————————————————————————————————————————–+
| PROCESS-ID | 1001 |
+—————–+——————————————————————————————————————————————————–+
| GMT-CREATE | 2018-07-17 18:39:12 |
+—————–+——————————————————————————————————————————————————–+
| COST(ms) | 1 |
+—————–+——————————————————————————————————————————————————–+
| OBJECT | 0x55b1388a |
+—————–+——————————————————————————————————————————————————–+
| CLASS | org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FSParentQueue |
+—————–+——————————————————————————————————————————————————–+
| METHOD | assignContainer |
+—————–+——————————————————————————————————————————————————–+
| IS-RETURN | true |
+—————–+——————————————————————————————————————————————————–+
| IS-EXCEPTION | false |
+—————–+——————————————————————————————————————————————————–+
| PARAMETERS[0] | host: datanode1:40231 #containers=1 available=9216 used=3072 |
+—————–+——————————————————————————————————————————————————–+
| RETURN-OBJ |
watch -n 3 -f org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FSParentQueue assignContainer returnObj
Press Ctrl+D to abort.
Affect(class-cnt:1 , method-cnt:1) cost in 127 ms.
<memory:0, vCores:0>
<memory:0, vCores:0>
<memory:0, vCores:0>
watch -n 3 -Eb org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FSParentQueue assignContainer params[0]+"->"+target.childQueues
Press Ctrl+D to abort.
Affect(class-cnt:1 , method-cnt:1) cost in 193 ms.
host: datanode1:40231 #containers=0 available=12288 used=0->[[root.default, demand=<memory:0, vCores:0>, running=<memory:0, vCores:0>, share=<memory:0, vCores:0>, w=<memory weight=2.0, cpu weight=2.0>], [root.deployop, demand=<memory:0, vCores:0>, running=<memory:0, vCores:0>, share=<memory:0, vCores:0>, w=<memory weight=2.0, cpu weight=2.0>], [root.hadoop, demand=<memory:0, vCores:0>, running=<memory:0, vCores:0>, share=<memory:0, vCores:0>, w=<memory weight=2.0, cpu weight=2.0>]]
host: datanode3:42755 #containers=0 available=12288 used=0->[[root.default, demand=<memory:0, vCores:0>, running=<memory:0, vCores:0>, share=<memory:0, vCores:0>, w=<memory weight=2.0, cpu weight=2.0>], [root.deployop, demand=<memory:0, vCores:0>, running=<memory:0, vCores:0>, share=<memory:0, vCores:0>, w=<memory weight=2.0, cpu weight=2.0>], [root.hadoop, demand=<memory:0, vCores:0>, running=<memory:0, vCores:0>, share=<memory:0, vCores:0>, w=<memory weight=2.0, cpu weight=2.0>]]
host: datanode5:37176 #containers=0 available=12288 used=0->[[root.default, demand=<memory:0, vCores:0>, running=<memory:0, vCores:0>, share=<memory:0, vCores:0>, w=<memory weight=2.0, cpu weight=2.0>], [root.deployop, demand=<memory:0, vCores:0>, running=<memory:0, vCores:0>, share=<memory:0, vCores:0>, w=<memory weight=2.0, cpu weight=2.0>], [root.hadoop, demand=<memory:0, vCores:0>, running=<memory:0, vCores:0>, share=<memory:0, vCores:0>, w=<memory weight=2.0, cpu weight=2.0>]]