blktrace是一款block层的trace工具,block层在IO路径上的位置:

一个IO的生命周期大约是:
● I/O enters block layer – it can be:
– Remapped onto another device (MD, DM)
– Split into 2 separate I/Os (alignment, size, ...)
– Added to the request queue
– Merged with a previous entry on the queue All I/Os end up on a request queue at some point
● At some later time, the I/O is issued to a device driver, and submitted to a device
● Later, the I/O is completed by the device, and its driver
 
 blkparse显示的各指标点示意:
 Q------->G------------>I--------->M------------------->D----------------------------->C
|-Q time-|-Insert time-|
|--------- merge time ------------|-merge with other IO|
|----------------scheduler time time-------------------|---driver,adapter,storagetime--|

|----------------------- await time in iostat output ----------------------------------|
其中:
Q2Q — time between requests sent to the block layer
Q2G — time
from a block I/O is queued to the time it gets a request allocated for it
G2I — time f
rom a request is allocated to the time it is Inserted into the device's queue
Q2M — time
from a block I/O is queued to the time it gets merged with an existing request
I2D — time
from a request is inserted into the device's queue to the time it is actually issued to the device
M2D — time from
a block I/O is merged with an exiting request until the request is issued to the device
D2C — service time of the request by the device
Q2C — total time spent in the block layer
for a request
下面通过示例简单介绍使用blktrace工具链分析IO的一般方法:
 
1,使用blktrace 抓取设备上的IO信息:
    blktrace -w 120 -d /dev/nvme0n1
   这会在本地目录下面生成device.blktrace.cpu命名的一堆二进制文件
 
2,使用blkparse读取blktrace生成的二进制文件:
      blkparse -i nvme0n1 -d blkparse.out
      这个命令会将分析结果输出到屏幕,并且将分析结果的二进制数据输出到blkparse.out文件中
 
3,使用btt查看和分析各种IO相关数据
3.1 使用btt查看IO的整体情况:
     btt -i blkparse.out

上图中几个X2Y的解释:

Q2I – time it takes to process an I/O prior to it being inserted or merged onto a request queue – Includes split, and remap time

I2D – time the I/O is “idle” on the request queue

D2C – time the I/O is “active” in the driver and on the device

Q2I + I2D + D2C = Q2C

Q2C: Total processing time of the I/O

可以看到设备处理时间D2C占整个处理时间Q2C的91.95%
 
3.3 使用btt查看每个请求的latency的详细情况:
btt -i blkparse.out  -q q2c.lat
 它会生成下面这些文件:
-rw-r--r-- 1 root root     876 Jun 13 18:14 sys_mbps_fp.dat
-rw-r--r-- 1 root root     451 Jun 13 18:14 sys_iops_fp.dat
-rw-r--r-- 1 root root  429815 Jun 13 18:14 q2c.lat_259,6_q2c.dat
-rw-r--r-- 1 root root     876 Jun 13 18:14 259,6_mbps_fp.dat
-rw-r--r-- 1 root root     451 Jun 13 18:14 259,6_iops_fp.dat
 
sys_mbps_fs.dat中是本次统计中所有设备吞吐量,sys_iops_fp.dat中是本次统计中所有设备的IOPS,q2c.lat_259,6_q2c.dat中是每个请求的q2c的latency详情:

第一列表示时间(以秒为单位),第二列表示每个请求的q2c处理时间
也可以用-l查看d2c的latency
 
3.4 使用btt查看IO pattern
btt -i blkparse.out -B offset
它会生成三个文件:
-rw-r--r-- 1 root root  819132 Jun 13 18:21 offset_259,6_w.dat
-rw-r--r-- 1 root root     108 Jun 13 18:21 offset_259,6_r.dat
-rw-r--r-- 1 root root  819240 Jun 13 18:21 offset_259,6_c.dat
           prefix_device_r.dat
                  All read block numbers are output, first column is time (seconds), second is the block number, and the third column is the ending block number.
           prefix_device_w.dat
                  All write block numbers are output, first column is time (seconds), second is the block number, and the third column is the ending block number.
           prefix_device_c.dat
                  All block numbers (read and write) are output, first column is time (seconds), second is the block number, and the third column is the ending block number.

 
 
4,高级功能
blkparse的 -f 选项能从trace数据中抓取特定的信息输出。
比如:

blkparse -i nvme0n1.blktrace.* -f "%5T.%9t, %p, %C, %a, %d, %N\n" -a complete -o output.txt
它会将进程号(%p),进程名(%C),操作类型(%a),LBA号(%d)和LBA个数(%N)这些信息输出到output.txt中:

其他格式化参数请man blkparse。

更多用法请参考man blktrace和man blkparse.

值得一提的是,blktrace对应用程序的性能影响极小,作者是这么说的:Seeing less than 2% hits to application performance in relatively stressful I/O situations。


blktrace + blkparse + btt 分析IO的更多相关文章

  1. 利用BLKTRACE分析IO性能

    在Linux系统上,如果I/O发生性能问题,有没有办法进一步定位故障位置呢?iostat等最常用的工具肯定是指望不上的,[容易被误读的iostat]一文中解释过await表示单个I/O所需的平均时间, ...

  2. [转] 利用BLKTRACE分析IO性能

    在Linux系统上,如果I/O发生性能问题,有没有办法进一步定位故障位置呢?iostat等最常用的工具肯定是指望不上的,[容易被误读的iostat]一文中解释过await表示单个I/O所需的平均时间, ...

  3. blktrace分析IO

    http://bean-li.github.io/blktrace-to-report/ 前言 上篇博客介绍了iostat的一些输出,这篇介绍blktrace这个神器.上一节介绍iostat的时候,我 ...

  4. [转载]blktrace分析IO

    前言 上篇博客介绍了iostat的一些输出,这篇介绍blktrace这个神器.上一节介绍iostat的时候,我们心心念念希望得到块设备处理io的service time,而不是service time ...

  5. Linux 使用iostat分析IO性能

    原文:http://www.cnblogs.com/bangerlee/articles/2547161.html 对于I/O-bond类型的进程,我们经常用iostat工具查看进程IO请求下发的数量 ...

  6. 使用iostat分析IO性能

    对于I/O-bond类型的进程,我们经常用iostat工具查看进程IO请求下发的数量.系统处理IO请求的耗时,进而分析进程与操作系统的交互过程中IO方面是否存在瓶颈. 下面通过iostat命令使用实例 ...

  7. 利用MDK4中的逻辑分析仪分析IO口的PWM波

    1.先设置软件仿真 ,可参看STM32不完全手册的2.4的软件仿真这一章 (原文件名:1.jpg) Example functionality:                             ...

  8. PERCONA-TOOLKIT : pt-ioprofile分析IO情况

    针对IO密集型应用做系统调优的时候,我们通常都需要知道系统cpu  内存  io 网络等系统性能 和 使用率,结合应用本身的访问量,以及 mysql的性能指标来综合分析.比如说:我们将系统压力情况分为 ...

  9. JAVA基础之——JDK分析io、nio

    在哪儿:jdk\jre\lib\rt.jar package java.io;   package java.nio; 1 分类 1.1 IO 持久化序列化对象并压缩步骤 new FileOutput ...

随机推荐

  1. AI 经典书单 | 人工智能学习该读哪些书

    转载 2018年01月16日 00:00:00   人工智能相关岗位中,涉及到的内容包含: 算法.深度学习.机器学习.自然语言处理.数据结构.Tensorflow.Python .数据挖掘.搜索开发. ...

  2. SpringBoot整合Quartz定时任务 的简单实例

    POM.XML文件 <!-- 定时器任务 quartz需要导入的坐标 --> <dependency> <groupId>org.quartz-scheduler& ...

  3. 手把手实现腾讯qq拖拽删去效果(一)

    qq拖拽删除的效果,简单又好用,今天我就叫大家实现吧. 这个滑动效果,有何难点了,就是响应每行的点击事件了,为了完成这个任务,并且能够实现动画的效果了,我重写了一个slideview这个控件,这个控件 ...

  4. 用条件随机场CRF进行字标注中文分词(Python实现)

    http://www.tuicool.com/articles/zq2yyi   http://blog.csdn.net/u010189459/article/details/38546115 主题 ...

  5. PHP 使用PHPExcel删除Excel单元格指定列

    需求是这样的: 有一个系统仅公司内部和外部经销商使用,在一个导出功能中公司内部员工跟外部经销商导出的列是不一样的(某些数据是不能提供给经销商的) 因为导出的数据都是一样的(某些列外数据外部没有)因此并 ...

  6. Git 以分支的方式同时管理多个项目

    你是否遇到过这样的问题: 你的客户在你们这边做了N个项目,而项目之间又存在着某些业务关联(数据库访问等) 之前你可能是这样处理的,为客户的每个项目创建单独的Git版本 PC项目 手机项目 微信项目 其 ...

  7. List,Set,Map存取元素各有什么特点

    一丶存放 List存放元素是有序,可重复 Set存放元素无序,不可重复 Map元素键值对形式存放,键无序不可重复,值可重复 二丶取出 List取出元素for循环,foreach循环,Iterator迭 ...

  8. Material Design学习之 ProgreesBar

    转载奇怪注明出处:王亟亟的大牛之路 继续我们Material Design的内容,这一篇讲的是进度条,上一篇是Switch地址例如以下:http://blog.csdn.net/ddwhan0123/ ...

  9. mysql下载安装使用教程

    今天花了点时间终于把mysql安装好了,哈哈!下面上干货! (1)从官网下载mysql.地址https://www.mysql.com/ 图:按照图上的步骤就能找到 a.首页点击    DOWNLOA ...

  10. (纪录片)你必须知道的科学 The Science That You Have To Know (2014)

    简介: 类型: 纪录片制片国家/地区: 英国语言: 英语上映日期: 2014-2片长: 150分钟 主要内容: 你有没有认真想过,自己的身体有多奇妙?人体是世间最复杂的一项工程杰作,他也带来了一些非常 ...