eMMC读写性能和稳定性验证

本文主要讲述使用iozonedd/cp/rm命令、fioflashbench进行eMMC读写性能和稳定性测试。读写性能主要是通过iozone测试,稳定性主要是通过长时间随机读写进行测试。


iozone进行读写性能测试

在之前的文章中,我们介绍了iozone的使用,以及进行简单的读写测试。使用如下命令循环进行长时间读写测试:

1
while true; do /var/iozone -azecI -+n -L64 -S32 -r2m -s128m -i0 -i2 -+b 400000,30000 -w -f testfile; sleep 5; done

输出结果类似如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#while true; do /var/iozone -azecI -+n -L64 -S32 -r2m -s128m -i0 -i2 -+b 400000,30000 -w -f testfile; sleep 10; done
Iozone: Performance Test of File I/O
Version $Revision: 3.482 $
Compiled for 64 bit mode.
Build: linux-arm

Contributors:William Norcott, Don Capps, Isom Crawford, Kirby Collins
Al Slater, Scott Rhine, Mike Wisner, Ken Goss
Steve Landherr, Brad Smith, Mark Kelly, Dr. Alain CYR,
Randy Dunlap, Mark Montague, Dan Million, Gavin Brebner,
Jean-Marc Zucconi, Jeff Blomberg, Benny Halevy, Dave Boone,
Erik Habbinga, Kris Strecker, Walter Wong, Joshua Root,
Fabrice Bacchella, Zhenghua Xue, Qin Li, Darren Sawyer,
Vangel Bojaxhi, Ben England, Vikentsi Lapa,
Alexey Skidanov, Sudhir Kumar.

Run began: Thu Jan 1 00:43:42 1970

Auto Mode
Cross over of record size disabled.
Include fsync in write timing
Include close in write timing
O_DIRECT feature enabled
No retest option selected
Record Size 2048 kB
File size set to 131072 kB
Setting no_unlink
Command line used: ./iozone -azecI -+n -L64 -S32 -r2m -s128m -i0 -i2 -+b 400000,30000 -w -f testfile
Output is in kBytes/sec
Time Resolution = 0.000001 seconds.
Processor cache size set to 32 kBytes.
Processor cache line size set to 64 bytes.
File stride size set to 17 * record size.
Burst size set to 400000 Kbytes.
Burst sleep duration set to 30000 msec
random random bkwd record stride
kB reclen write rewrite read reread read write read rewrite read fwrite frewrite fread freread
131072 2048 29113 0 120309 30641

iozone test complete.
Iozone: Performance Test of File I/O
Version $Revision: 3.482 $
Compiled for 64 bit mode.
Build: linux-arm

Contributors:William Norcott, Don Capps, Isom Crawford, Kirby Collins
Al Slater, Scott Rhine, Mike Wisner, Ken Goss
Steve Landherr, Brad Smith, Mark Kelly, Dr. Alain CYR,
Randy Dunlap, Mark Montague, Dan Million, Gavin Brebner,
Jean-Marc Zucconi, Jeff Blomberg, Benny Halevy, Dave Boone,
Erik Habbinga, Kris Strecker, Walter Wong, Joshua Root,
Fabrice Bacchella, Zhenghua Xue, Qin Li, Darren Sawyer,
Vangel Bojaxhi, Ben England, Vikentsi Lapa,
Alexey Skidanov, Sudhir Kumar.

Run began: Thu Jan 1 00:44:03 1970

Auto Mode
Cross over of record size disabled.
Include fsync in write timing
Include close in write timing
O_DIRECT feature enabled
No retest option selected
Record Size 2048 kB
File size set to 131072 kB
Setting no_unlink
Command line used: ./iozone -azecI -+n -L64 -S32 -r2m -s128m -i0 -i2 -+b 400000,30000 -w -f testfile
Output is in kBytes/sec
Time Resolution = 0.000001 seconds.
Processor cache size set to 32 kBytes.
Processor cache line size set to 64 bytes.
File stride size set to 17 * record size.
Burst size set to 400000 Kbytes.
Burst sleep duration set to 30000 msec
random random bkwd record stride
kB reclen write rewrite read reread read write read rewrite read fwrite frewrite fread freread
131072 2048 27780 0 131062 31161
......

上述测试可以放置测试,看看emmc或者文件系统有没有报错。然后我们可以将测试过程中的log保存为一个文件,通过python去解析读写速度并将其输出到excel表格中。再通过图表的形式,看读写速度是不是稳定持续,有没有出现突变的情况。比如我测试的读写速度输出如下,当然,这里面的格式可以稍微整理一下。
eMMC读写性能和稳定性验证-1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/python
#-*- coding:utf-8 -*-

import operator
import xlwt

file = open("./emmc_test.txt")
line = 0
list = []

while 1:
content = file.readline()
if not content:
break
line = line+1
content=content.strip('\n')
iscomplete = content.startswith(" 131072")
if iscomplete == 1:
# 读速度
#print("%d: %s\n" %(line-1,content))

# 读速度
read_start_index = 63
read_end_index = 69
read_speed_str = content[read_start_index:read_end_index]
read_speed = int(read_speed_str)
# print("%d, %d, %d\n" %(read_start_index, read_end_index, read_speed))

# 写速度
write_start_index = 73
write_end_index = 78
write_speed_str = content[write_start_index:write_end_index]
write_speed = int(write_speed_str)
#print("%d, %d, %d\n" %(write_start_index, write_end_index, write_speed))
list.append((read_speed, write_speed))


# 写入到excel表格中
data=xlwt.Workbook()
table=data.add_sheet("emmc")
table.write(0, 0, u'读速度')
table.write(0, 1, u'写速度')

for i in range(0, len(list)):
for j in range(0, 2):
table.write(i+1, 1-j, list[i][j])
data.save("output.xls")


dd/cp命令进行读写压力测试

关于dd命令的详细使用,可以参照:https://www.gnu.org/software/coreutils/manual/html_node/dd-invocation.html
在下面的脚本中,测试dd多次读写100M的文件,当然,可以将dd命令替换成cp命令测试。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash

echo "eMMC dd test start ...."
test_times=100000
i=0
while(($i < $test_times))
do
printf "test count: %d\n" $i
echo "dd write test"
time dd if=/dev/zero of=/var/temp bs=512 count=204800
sync

echo "dd read test"
time dd if=/var/temp of=/dev/null bs=512 count=204800
sync

echo "remove temp file"
rm -rf /var/temp
sync

echo "drop caches"
echo 1 > /proc/sys/vm/drop_caches
sleep 1
i=$(($i+1))
printf "\n\n"
done

上面的是带文件系统的读写,如果要测试直接IO读写,需要给dd命令加上iflag=direct,nonblockoflag=direct,nonblock的参数。关于这两个参数的解释,详见:
http://blog.sina.com.cn/s/blog_5d9051c00100g4aj.html
https://blog.csdn.net/menogen/article/details/38059671

但是我这边使用的dd命令版本不支持这两个参数,可下载dd源码自行交叉编译:
https://www.gnu.org/software/coreutils/coreutils.html
https://unix.stackexchange.com/questions/189804/how-can-i-cross-compile-the-dd-linux-tool-for-arm


fio性能测试工具

fioflexible I/O tester,是一个工具,它将生成许多线程或进程,执行用户指定的特定类型的IO操作。fio的典型用法是编写与想要模拟的IO负载匹配的作业文件。fio是一个专业的测试IO性能的工具,不太适用于我们的测试场景,以下内容只是作为简单的了解使用。
https://github.com/axboe/fio clone一个source code下来,然后交叉编译生成fio,测试命令为:

1
# ./fio -filename=/dev/block/mmcblk0 -direct=1 -iodepth 1 -thread -rw=read -ioengine=psync -bs=16k -numjobs=30 -runtime=60 -group_reporting -name="IORTest"

得到的结果为:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
IORTest: (g=0): rw=read, bs=(R) 16.0KiB-16.0KiB, (W) 16.0KiB-16.0KiB, (T) 16.0KiB-16.0KiB, ioengine=psync, iodepth=1
...
fio-3.11-21-g307f
Starting 30 threads
Jobs: 30 (f=30): [R(30)][100.0%][r=43.4MiB/s][r=2778 IOPS][eta 00m:00s]
IORTest: (groupid=0, jobs=30): err= 0: pid=1533: Thu Jan 1 00:01:22 1970
read: IOPS=3050, BW=47.7MiB/s (49.0MB/s)(2860MiB/60019msec)
clat (usec): min=351, max=6205.4k, avg=9827.33, stdev=180070.72
lat (usec): min=353, max=6205.4k, avg=9828.22, stdev=180070.72
clat percentiles (usec):
| 1.00th=[ 791], 5.00th=[ 799], 10.00th=[ 816],
| 20.00th=[ 832], 30.00th=[ 848], 40.00th=[ 979],
| 50.00th=[ 1012], 60.00th=[ 1057], 70.00th=[ 1074],
| 80.00th=[ 1090], 90.00th=[ 1090], 95.00th=[ 1106],
| 99.00th=[ 1221], 99.50th=[ 1565], 99.90th=[3774874],
| 99.95th=[4328522], 99.99th=[5268046]
bw ( KiB/s): min= 31, max=19232, per=13.03%, avg=6358.74, stdev=5584.55, samples=914
iops : min= 1, max= 1202, avg=396.95, stdev=349.09, samples=915
lat (usec) : 500=0.01%, 750=0.45%, 1000=46.08%
lat (msec) : 2=53.04%, 4=0.03%, 10=0.01%, 20=0.01%, 50=0.01%
lat (msec) : 100=0.01%, 250=0.05%, 500=0.05%, 750=0.01%, 1000=0.01%
cpu : usr=0.10%, sys=0.35%, ctx=183434, majf=0, minf=153
IO depths : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%
submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
issued rwts: total=183066,0,0,0 short=0,0,0,0 dropped=0,0,0,0
latency : target=0, window=0, percentile=100.00%, depth=1

Run status group 0 (all jobs):
READ: bw=47.7MiB/s (49.0MB/s), 47.7MiB/s-47.7MiB/s (49.0MB/s-49.0MB/s), io=2860MiB (2999MB), run=60019-60019msec

Disk stats (read/write):
mmcblk0: ios=182797/0, merge=29/0, ticks=2051544/0, in_queue=2144416, util=100.00%

关于参数的说明可以参照:
https://linux.die.net/man/1/fio
https://github.com/axboe/fio/blob/master/HOWTO

关于输出结果的解释说明,可以参照:
https://tobert.github.io/post/2014-04-17-fio-output-explained.html

用法的例子可以参照:
https://blog.csdn.net/jiecxy/article/details/58197387?utm_source=blogxgwz10
https://blog.csdn.net/m0_37972390/article/details/80019762
https://www.jianshu.com/p/9d823b353f22


flashbench

flashbench是用于识别linaro闪存调查的SD卡和其他媒体属性的工具。
参考资料:
https://github.com/bradfa/flashbench
https://lwn.net/Articles/428584/
https://blog.csdn.net/luckywang1103/article/details/53175368?locationNum=10&fps=1
https://wiki.linaro.org/WorkingGroups/KernelArchived/Projects/FlashCardSurvey

Title:eMMC读写性能和稳定性验证

Author:Victor Huang

Time:2019-03-17 / 16:03

Link:http://wowothink.com/7ffb6593/

License: Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)