runqlen从字面意思,很简单的看出其是统计运行队列的长度的
废话少说,从help开始
usage: runqlen [-h] [-T] [-O] [-C] [interval] [count] Summarize scheduler run queue length as a histogram positional arguments: interval output interval, in seconds count number of outputs optional arguments: -h, --help show this help message and exit -T, --timestamp include timestamp on output #显示时间戳 -O, --runqocc report run queue occupancy #统计运行队列的占有率,不明白怎么统计的 -C, --cpus print output for each CPU separately #单独打印每个cpu的队列的长度
./runqlen
显示每一次采样时运行队列的长度
Sampling run queue length... Hit Ctrl-C to end. ^C runqlen : count distribution 0 : 1068 |****************************************| 1 : 642 |************************ | 2 : 369 |************* | 3 : 183 |****** | 4 : 104 |*** | 5 : 42 |* | 6 : 13 | | 7 : 2 | | 8 : 1 | |
当队列长度为8时,引发时延
Sampling run queue length... Hit Ctrl-C to end. ^C runqlen : count distribution 0 : 1209 |****************************************| 1 : 372 |************ | 2 : 73 |** | 3 : 3 | | 4 : 1 | | 5 : 0 | | 6 : 0 | | 7 : 237 |******* |
这个显示队列长度为7的次数,说明任务还是比较频繁的
./runqlen -C
显示每一个cpu的运行队列的矩形图
cpu = 0 runqlen : count distribution 0 : 257 |****************************************| 1 : 64 |********* | 2 : 5 | | 3 : 0 | | 4 : 0 | | 5 : 0 | | 6 : 1 | | cpu = 1 runqlen : count distribution 0 : 226 |****************************************| 1 : 90 |*************** | 2 : 11 |* | cpu = 2 runqlen : count distribution 0 : 264 |****************************************| 1 : 52 |******* | 2 : 8 |* | 3 : 1 | | 4 : 0 | | 5 : 0 | | 6 : 1 | | 7 : 0 | | 8 : 1 | | cpu = 3 runqlen : count distribution 0 : 0 | | 1 : 0 | | 2 : 0 | | 3 : 0 | | 4 : 0 | | 5 : 0 | | 6 : 0 | | 7 : 327 |****************************************|
从图中可以看出,cpu3运行队列长度长期处于7的状态,在考虑负载均衡的情况下,很有可能很多任务都被强制绑定到了cpu3上
./runqlen -T 1 5
./runqlen -T 1 5 Sampling run queue length... Hit Ctrl-C to end. 19:51:34 runqlen : count distribution 0 : 635 |****************************************| 1 : 142 |******** | 2 : 13 | | 3 : 0 | | 4 : 1 | | 19:51:35 runqlen : count distribution 0 : 640 |****************************************| 1 : 136 |******** | 2 : 13 | | 3 : 1 | | 4 : 0 | | 5 : 0 | | 6 : 0 | | 7 : 0 | | 8 : 0 | | 9 : 0 | | 10 : 1 | |
每隔一秒采样一次,采样五次,并显示时间戳
./runqlen -OT 1
显示运行队列被任务占用的情况
Sampling run queue length... Hit Ctrl-C to end. 19:54:53 runqocc: 41.09% 19:54:54 runqocc: 41.85% 19:54:55 runqocc: 41.47% 19:54:56 runqocc: 42.35%
./runqlen -COT 1
每隔1s显示每一个cpu运行队列占用率情况,并显示时间戳
19:55:03 runqocc, CPU 0 32.32% runqocc, CPU 1 26.26% runqocc, CPU 2 38.38% runqocc, CPU 3 100.00% runqocc, CPU 4 26.26% runqocc, CPU 5 32.32% runqocc, CPU 6 39.39% runqocc, CPU 7 46.46% 19:55:04 runqocc, CPU 0 35.00% runqocc, CPU 1 32.32% runqocc, CPU 2 37.00% runqocc, CPU 3 100.00% runqocc, CPU 4 43.43% runqocc, CPU 5 31.31% runqocc, CPU 6 28.00% runqocc, CPU 7 31.31%