python实践之fio-bench

2019-09-08

本博客所有文章采用的授权方式为 自由转载-非商用-非衍生-保持署名 ,转载请务必注明出处,谢谢。


背景

性能测试时,需要手动执行fio的很多命令,并且记录fio结果时,需要靠人眼来识别,效率低下,为了批量执行一些列fio命令,并且自动整理出结果。

项目地址:https://gitlab.com/dragon200518/my-own/tree/master/PYTHON/seg-fio-bench

依赖说明

依赖python 的tablulate库,(参考need_install_deb_or_rpm 目录)

目前对 fio-3.8的json result 解析有问题。fio-2.* 的版本上没有问题

centos7.6 的版本发现,系统自带fio-3.1 版本,需要 用 fio-2.* 版本替换。(need_install_deb_or_rpm 目录包括了该版本)

example

执行单个 fio job

其中 -r 是指 fio 中的runtime,秒为单位

[root@localhost seg-fio-bench]# python segbench -j iscsi_randw_4kb_iodepth_32 -d /dev/sdb -s 1G -r 10


         =========  result of iscsi_randw_4kb_iodepth_32  =========      
| type   |   iops |   bandwidth(MB) |   latency_avg(us) |   latency_90% |   latency_95% |   latency_99% |   latency_99.9% |
|--------+--------+-----------------+-------------------+---------------+---------------+---------------+-----------------|
| write  |   1383 |            5535 |             23112 |         56576 |         83456 |        177152 |          448512 |
[root@localhost seg-fio-bench]# 

执行所有 fio job

[root@localhost seg-fio-bench]# python segbench  -d /dev/sdb -s 1G -r 10


         =========  result of iscsi_rand7r3w_4kb_iodepth_1  =========      
| type   |   iops |   bandwidth(MB) |   latency_avg(us) |   latency_90% |   latency_95% |   latency_99% |   latency_99.9% |
|--------+--------+-----------------+-------------------+---------------+---------------+---------------+-----------------|
| read   |     10 |              41 |           86006.1 |        209920 |        246784 |        733184 |         1679360 |
| write  |      5 |              22 |           17691.9 |         43264 |         80384 |        162816 |          162816 |


         =========  result of iscsi_rand7r3w_4kb_iodepth_32  =========      
| type   |   iops |   bandwidth(MB) |   latency_avg(us) |   latency_90% |   latency_95% |   latency_99% |   latency_99.9% |
|--------+--------+-----------------+-------------------+---------------+---------------+---------------+-----------------|
| read   |    584 |            2337 |           40308   |        107008 |        177152 |        485376 |         1466368 |
| write  |    242 |             969 |           34808.3 |         85504 |        120320 |        325632 |         1302528 |



fio-3.* 的json 和 fio-2.* json的输出记录

直接用 fio-3.*的报错记录如下:

centos7 上,fio3.8版本 执行报错
[root@centos-1 seg-fio-bench]# python segbench -d /dev/sdb -s 1G -r 10
counter exception: 'lat'

[root@centos-1 seg-fio-bench]# python segbench -j iscsi_rand7r3w_4kb_iodepth_1 -d /dev/sdb -s 1G -r 10
begin format fio result
Traceback (most recent call last):
  File "segbench", line 275, in <module>
    exit(main())
  File "segbench", line 264, in main
    do_fio_job(options.job_id,options.destination,options.size,options.runtime_of_each_job)
  File "segbench", line 140, in do_fio_job
    fio_result_format(data,job_id)
  File "segbench", line 197, in fio_result_format
    result['read_latency_avg']=data['jobs'][0]['read']['lat']['mean']
KeyError: 'lat'

原因是,fio 3.8 的json结果里,延迟的key 从 lat 变为了lat_ns

fio-3.*

{
  "fio version" : "fio-3.1",
  "timestamp" : 1569307619,
  "timestamp_ms" : 1569307619855,
  "time" : "Tue Sep 24 14:46:59 2019",
  "jobs" : [
    {
      "jobname" : "seqwrite",
      "groupid" : 0,
      "error" : 0,
      "eta" : 0,
      "elapsed" : 74,
      "job options" : {
        "name" : "seqwrite",
        "rw" : "write",
        "bs" : "1M",
        "size" : "20G",
        "runtime" : "1200",
        "ioengine" : "libaio",
        "iodepth" : "64",
        "numjobs" : "1",
        "filename" : "/dev/sdc",
        "direct" : "1"
      },
      "read" : {
        "io_bytes" : 0,
        "io_kbytes" : 0,
        "bw" : 0,
        "iops" : 0.000000,
        "runtime" : 0,
        "total_ios" : 0,
        "short_ios" : 0,
        "drop_ios" : 0,
        "slat_ns" : {
          "min" : 0,
          "max" : 0,
          "mean" : 0.000000,
          "stddev" : 0.000000
        },
        "clat_ns" : {
          "min" : 0,
          "max" : 0,
          "mean" : 0.000000,
          "stddev" : 0.000000,
          "percentile" : {
            "1.000000" : 0,
            "5.000000" : 0,
            "10.000000" : 0,
            "20.000000" : 0,
            "30.000000" : 0,
            "40.000000" : 0,
            "50.000000" : 0,
            "60.000000" : 0,
            "70.000000" : 0,
            "80.000000" : 0,
            "90.000000" : 0,
            "95.000000" : 0,
            "99.000000" : 0,
            "99.500000" : 0,
            "99.900000" : 0,
            "99.950000" : 0,
            "99.990000" : 0,
            "0.00" : 0,
            "0.00" : 0,
            "0.00" : 0
          }
        },
        "lat_ns" : {
          "min" : 0,
          "max" : 0,
          "mean" : 0.000000,
          "stddev" : 0.000000
        },
        "bw_min" : 0,
        "bw_max" : 0,
        "bw_agg" : 0.000000,
        "bw_mean" : 0.000000,
        "bw_dev" : 0.000000,
        "bw_samples" : 0,
        "iops_min" : 0,
        "iops_max" : 0,
        "iops_mean" : 0.000000,
        "iops_stddev" : 0.000000,
        "iops_samples" : 0
      },
      "write" : {
        "io_bytes" : 21474836480,
        "io_kbytes" : 20971520,
        "bw" : 285086,
        "iops" : 278.404611,
        "runtime" : 73562,
        "total_ios" : 20480,
        "short_ios" : 0,
        "drop_ios" : 0,
        "slat_ns" : {
          "min" : 59285,
          "max" : 534211,
          "mean" : 189834.695508,
          "stddev" : 35219.074055
        },
        "clat_ns" : {
          "min" : 10390250,
          "max" : 704011844,
          "mean" : 229664283.847021,
          "stddev" : 42501151.327277,
          "percentile" : {
            "1.000000" : 191889408,
            "5.000000" : 202375168,
            "10.000000" : 206569472,
            "20.000000" : 210763776,
            "30.000000" : 212860928,
            "40.000000" : 217055232,
            "50.000000" : 219152384,
            "60.000000" : 221249536,
            "70.000000" : 223346688,
            "80.000000" : 227540992,
            "90.000000" : 242221056,
            "95.000000" : 354418688,
            "99.000000" : 375390208,
            "99.500000" : 396361728,
            "99.900000" : 497025024,
            "99.950000" : 574619648,
            "99.990000" : 633339904,
            "0.00" : 0,
            "0.00" : 0,
            "0.00" : 0
          }
        },
        "lat_ns" : {
          "min" : 10491324,
          "max" : 704221005,
          "mean" : 229854855.581249,
          "stddev" : 42502056.979064
        },
        "bw_min" : 137216,
        "bw_max" : 311296,
        "bw_agg" : 99.775253,
        "bw_mean" : 284445.278912,
        "bw_dev" : 15304.766126,
        "bw_samples" : 147,
        "iops_min" : 134,
        "iops_max" : 304,
        "iops_mean" : 277.768707,
        "iops_stddev" : 14.946053,
        "iops_samples" : 147
      },
      "trim" : {
        "io_bytes" : 0,
        "io_kbytes" : 0,
        "bw" : 0,
        "iops" : 0.000000,
        "runtime" : 0,
        "total_ios" : 0,
        "short_ios" : 0,
        "drop_ios" : 0,
        "slat_ns" : {
          "min" : 0,
          "max" : 0,
          "mean" : 0.000000,
          "stddev" : 0.000000
        },
        "clat_ns" : {
          "min" : 0,
          "max" : 0,
          "mean" : 0.000000,
          "stddev" : 0.000000,
          "percentile" : {
            "1.000000" : 0,
            "5.000000" : 0,
            "10.000000" : 0,
            "20.000000" : 0,
            "30.000000" : 0,
            "40.000000" : 0,
            "50.000000" : 0,
            "60.000000" : 0,
            "70.000000" : 0,
            "80.000000" : 0,
            "90.000000" : 0,
            "95.000000" : 0,
            "99.000000" : 0,
            "99.500000" : 0,
            "99.900000" : 0,
            "99.950000" : 0,
            "99.990000" : 0,
            "0.00" : 0,
            "0.00" : 0,
            "0.00" : 0
          }
        },
        "lat_ns" : {
          "min" : 0,
          "max" : 0,
          "mean" : 0.000000,
          "stddev" : 0.000000
        },
        "bw_min" : 0,
        "bw_max" : 0,
        "bw_agg" : 0.000000,
        "bw_mean" : 0.000000,
        "bw_dev" : 0.000000,
        "bw_samples" : 0,
        "iops_min" : 0,
        "iops_max" : 0,
        "iops_mean" : 0.000000,
        "iops_stddev" : 0.000000,
        "iops_samples" : 0
      },
      "usr_cpu" : 2.419760,
      "sys_cpu" : 3.992605,
      "ctx" : 18745,
      "majf" : 0,
      "minf" : 9,
      "iodepth_level" : {
        "1" : 0.100000,
        "2" : 0.100000,
        "4" : 0.100000,
        "8" : 0.100000,
        "16" : 0.100000,
        "32" : 0.156250,
        ">=64" : 99.692383
      },
      "latency_ns" : {
        "2" : 0.000000,
        "4" : 0.000000,
        "10" : 0.000000,
        "20" : 0.000000,
        "50" : 0.000000,
        "100" : 0.000000,
        "250" : 0.000000,
        "500" : 0.000000,
        "750" : 0.000000,
        "1000" : 0.000000
      },
      "latency_us" : {
        "2" : 0.000000,
        "4" : 0.000000,
        "10" : 0.000000,
        "20" : 0.000000,
        "50" : 0.000000,
        "100" : 0.000000,
        "250" : 0.000000,
        "500" : 0.000000,
        "750" : 0.000000,
        "1000" : 0.000000
      },
      "latency_ms" : {
        "2" : 0.000000,
        "4" : 0.000000,
        "10" : 0.000000,
        "20" : 0.010000,
        "50" : 0.010000,
        "100" : 0.083008,
        "250" : 90.498047,
        "500" : 9.306641,
        "750" : 0.097656,
        "1000" : 0.000000,
        "2000" : 0.000000,
        ">=2000" : 0.000000
      },
      "latency_depth" : 64,
      "latency_target" : 0,
      "latency_percentile" : 100.000000,
      "latency_window" : 0
    }
  ],
  "disk_util" : [
    {
      "name" : "sdc",
      "read_ios" : 0,
      "write_ios" : 40815,
      "read_merges" : 0,
      "write_merges" : 0,
      "read_ticks" : 0,
      "write_ticks" : 9094388,
      "in_queue" : 9109036,
      "util" : 99.867943
    }
  ]
}
root@node40:~# 

fio-2.*

{
    "jobs":[
        {
            "trim":{
                "io_bytes":0,
                "slat":{
                    "max":0,
                    "mean":0,
                    "stddev":0,
                    "min":0
                },
                "bw_max":0,
                "bw_mean":0,
                "iops":0,
                "bw":0,
                "lat":{
                    "max":0,
                    "mean":0,
                    "stddev":0,
                    "min":0
                },
                "bw_agg":0,
                "clat":{
                    "max":0,
                    "mean":0,
                    "percentile":{
                        "70.000000":0,
                        "5.000000":0,
                        "50.000000":0,
                        "99.990000":0,
                        "30.000000":0,
                        "10.000000":0,
                        "99.000000":0,
                        "0.00":0,
                        "90.000000":0,
                        "95.000000":0,
                        "60.000000":0,
                        "40.000000":0,
                        "20.000000":0,
                        "99.900000":0,
                        "99.950000":0,
                        "1.000000":0,
                        "99.500000":0,
                        "80.000000":0
                    },
                    "stddev":0,
                    "min":0
                },
                "runtime":0,
                "bw_min":0,
                "bw_dev":0
            },
            "latency_us":{
                "2":0,
                "4":0,
                "10":0,
                "20":0,
                "50":0,
                "100":0,
                "250":1.7,
                "500":19.97,
                "750":29.92,
                "1000":17.72
            },
            "latency_ms":{
                "2":20.85,
                "4":9.21,
                "10":0.62,
                "20":0.02,
                "50":0,
                "100":0,
                "250":0,
                "500":0,
                "750":0,
                "1000":0,
                "2000":0,
                ">=2000":0
            },
            "read":{
                "io_bytes":13880,
                "slat":{
                    "max":139,
                    "mean":14.17,
                    "stddev":7.33,
                    "min":7
                },
                "bw_max":2944,
                "bw_mean":2783.78,
                "iops":693,
                "bw":2775,
                "lat":{
                    "max":6043,
                    "mean":650.79,
                    "stddev":352.49,
                    "min":169
                },
                "bw_agg":2783.78,
                "clat":{
                    "max":6027,
                    "mean":636.41,
                    "percentile":{
                        "70.000000":740,
                        "5.000000":274,
                        "50.000000":652,
                        "99.990000":6048,
                        "30.000000":490,
                        "10.000000":306,
                        "99.000000":1912,
                        "0.00":0,
                        "90.000000":860,
                        "95.000000":924,
                        "60.000000":700,
                        "40.000000":596,
                        "20.000000":366,
                        "99.900000":4576,
                        "99.950000":6048,
                        "1.000000":225,
                        "99.500000":2768,
                        "80.000000":788
                    },
                    "stddev":352.13,
                    "min":160
                },
                "runtime":5001,
                "bw_min":2496,
                "bw_dev":153.99
            },
            "majf":0,
            "ctx":4886,
            "minf":1,
            "jobname":"config",
            "write":{
                "io_bytes":5628,
                "slat":{
                    "max":101,
                    "mean":15.95,
                    "stddev":8.23,
                    "min":7
                },
                "bw_max":1213,
                "bw_mean":1127.11,
                "iops":281,
                "bw":1125,
                "lat":{
                    "max":12967,
                    "mean":1940.59,
                    "stddev":664.97,
                    "min":1116
                },
                "bw_agg":1127.11,
                "clat":{
                    "max":12956,
                    "mean":1924.41,
                    "percentile":{
                        "70.000000":2008,
                        "5.000000":1384,
                        "50.000000":1864,
                        "99.990000":12992,
                        "30.000000":1704,
                        "10.000000":1464,
                        "99.000000":4512,
                        "0.00":0,
                        "90.000000":2224,
                        "95.000000":2448,
                        "60.000000":1928,
                        "40.000000":1768,
                        "20.000000":1592,
                        "99.900000":8896,
                        "99.950000":12992,
                        "1.000000":1272,
                        "99.500000":6240,
                        "80.000000":2096
                    },
                    "stddev":664.95,
                    "min":1090
                },
                "runtime":5001,
                "bw_min":1011,
                "bw_dev":71.2
            },
            "iodepth_level":{
                "1":100,
                "2":0,
                "4":0,
                "8":0,
                "16":0,
                "32":0,
                ">=64":0
            },
            "usr_cpu":1.24,
            "error":0,
            "sys_cpu":1,
            "groupid":0
        }
    ],
    "fio version":"fio-2.1.3",
    "disk_util":[
        {
            "read_merges":0,
            "name":"rbd2",
            "write_ios":1381,
            "read_ios":3563,
            "util":98.16,
            "read_ticks":2292,
            "write_merges":0,
            "in_queue":4896,
            "write_ticks":2604
        }
    ]
}

文章评论

comments powered by Disqus


章节列表