linux fio释放内存,Linux 中使用 Fio 测评硬盘性能

Fio(Flexible I/O Tester) 是一款由 Jens Axboe 开发的用于测评和压力/硬件验证的自由开源的软件。它支持 19 种不同类型的 I/O 引擎 (sync、mmap、libaio、posixaio、SG v3、splice、null、network、 syslet、guasi、solarisaio,以及更多), I/O 优先级(针对较新的 Linux 内核),I/O 速度,fork 的任务或线程任务等等。它能够在块设备和文件上工作。

Fio 接受一种非常简单易于理解的文本格式的任务描述。软件默认包含了几个示例任务文件。 Fio 展示了所有类型的 I/O 性能信息,包括完整的 IO 延迟和百分比。

它被广泛的应用在非常多的地方,包括测评、QA,以及验证用途。它支持 Linux 、FreeBSD 、NetBSD、 OpenBSD、 OS X、 OpenSolaris、 AIX、 HP-UX、 Android 以及 Windows。在这个教程,我们将使用 Ubuntu 16 ,你需要拥有这台电脑的 sudo 或 root 权限。我们将完整的进行安装和 Fio 的使用。

在 Debian 系统安装 Fio

对于 Debian 来说, Fio 已经在主仓库内。我们可以很容易的使用 apt-get 的包管理器安装。你只需要简单的执行下述命令:

sudo apt-get install fio

当然,你可以可以使用源代码,自己编译安装最新的版本。我们需要从 GitHub 上克隆最新的代码,安装所需的依赖,然后从源码构建应用。首先,确保我们安装了 Git ,

sudo apt-get install git

现在,我们切换到 /opt 目录,并从 Github 上克隆仓库:

cd /opt

git clone https://github.com/axboe/fio

现在,我们通过在 /opt 目录下切换到 Fio 的源代码目录,执行编译和安装操作了,命令如下:

# cd /opt/fio

# ./configure

# make

# make install

使用 Fio 进行磁盘性能测试

现在 Fio 已经安装到了你的系统中,我们一起看看如何使用 Fio 做磁盘的随机写、读和读写测试。

随机写测试

执行下面的命令来开始。这个命令将要同一时间执行两个进程,写入共计 4GB( 4 个任务 x 512MB = 2GB) 文件:

sudo fio --name=randwrite --ioengine=libaio --iodepth=1 --rw=randwrite --bs=4k --direct=0 --size=512M --numjobs=2 --runtime=240 --group_reporting

输出如下:

...

fio-2.2.10

Starting 2 processes

randwrite: (groupid=0, jobs=2): err= 0: pid=7271: Sat Aug 5 13:28:44 2017

write: io=1024.0MB, bw=2485.5MB/s, iops=636271, runt= 412msec

slat (usec): min=1, max=268, avg= 1.79, stdev= 1.01

clat (usec): min=0, max=13, avg= 0.20, stdev= 0.40

lat (usec): min=1, max=268, avg= 2.03, stdev= 1.01

clat percentiles (usec):

| 1.00th=[ 0], 5.00th=[ 0], 10.00th=[ 0], 20.00th=[ 0],

| 30.00th=[ 0], 40.00th=[ 0], 50.00th=[ 0], 60.00th=[ 0],

| 70.00th=[ 0], 80.00th=[ 1], 90.00th=[ 1], 95.00th=[ 1],

| 99.00th=[ 1], 99.50th=[ 1], 99.90th=[ 1], 99.95th=[ 1],

| 99.99th=[ 1]

lat (usec) : 2=99.99%, 4=0.01%, 10=0.01%, 20=0.01%

cpu : usr=15.14%, sys=84.00%, ctx=8, majf=0, minf=26

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 : total=r=0/w=262144/d=0, short=r=0/w=0/d=0, drop=r=0/w=0/d=0

latency : target=0, window=0, percentile=100.00%, depth=1

Run status group 0 (all jobs):

WRITE: io=1024.0MB, aggrb=2485.5MB/s, minb=2485.5MB/s, maxb=2485.5MB/s, mint=412msec, maxt=412msec

Disk stats (read/write):

sda: ios=0/0, merge=0/0, ticks=0/0, in_queue=0, util=0.00%

随机读测试

我们将要执行一个随机读测试,我们将会尝试读取一个随机的 2GB 文件。

sudo fio --name=randread --ioengine=libaio --iodepth=16 --rw=randread --bs=4k --direct=0 --size=512M --numjobs=4 --runtime=240 --group_reporting

最后,我们想要展示一个简单的随机读-写测试来看一看 Fio 返回的输出类型。

读写性能测试

下述命令将会测试 USB Pen 驱动器 (/dev/sdc1) 的随机读写性能:

sudo fio --randrepeat=1 --ioengine=libaio --direct=1 --gtod_reduce=1 --name=test --filename=random_read_write.fio --bs=4k --iodepth=64 --size=4G --readwrite=randrw --rwmixread=75

输出如下:

Starting 1 process

Jobs: 1 (f=1): [m(1)] [100.0% done] [217.8MB/74452KB/0KB /s] [55.8K/18.7K/0 iops] [eta 00m:00s]

test: (groupid=0, jobs=1): err= 0: pid=8475: Sat Aug 5 13:36:04 2017

read : io=3071.7MB, bw=219374KB/s, iops=54843, runt= 14338msec

write: io=1024.4MB, bw=73156KB/s, iops=18289, runt= 14338msec

cpu : usr=6.78%, sys=20.81%, ctx=1007218, majf=0, minf=9

IO depths : 1=0.1%, 2=0.1%, 4=0.1%, 8=0.1%, 16=0.1%, 32=0.1%, >=64=100.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.1%, >=64=0.0%

issued : total=r=786347/w=262229/d=0, short=r=0/w=0/d=0, drop=r=0/w=0/d=0

latency : target=0, window=0, percentile=100.00%, depth=64

Run status group 0 (all jobs):

READ: io=3071.7MB, aggrb=219374KB/s, minb=219374KB/s, maxb=219374KB/s, mint=14338msec, maxt=14338msec

WRITE: io=1024.4MB, aggrb=73156KB/s, minb=73156KB/s, maxb=73156KB/s, mint=14338msec, maxt=14338msec

Disk stats (read/write):

sda: ios=774141/258944, merge=1463/899, ticks=748800/150316, in_queue=900720, util=99.35%

Fio 是一个非常有用的工具,并且我们希望你能在你下一次 Debugging 活动中使用到它。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值