[linux]linuxI/O测试的方法之dd

参考http://www.thomas-krenn.com/en/wiki/Linux_I/O_Performance_Tests_using_dd

Measuring Write Performance

Modern operating systems do not normally write files immediately to RAID systems or hard disks. Temporary memory that is not currently in use will be used to cache writes and reads (regarding this, see also Operating System Caches).

So that I/O performance measurements will not be affected by these caches (temporary memory), the oflag parameter can be used. Thereby, the following two flags are interesting (for details, see dd --help and Dd using direct or synchronized I/O):

  • direct (use direct I/O for data)
  • dsync (use synchronized I/O for data)
  • sync (likewise, but also for metadata)

For measuring write performance, the data to be written should be read from /dev/zero[2] and ideally written it to an empty RAID array, hard disk or partition (such as using of=/dev/sda for the first hard disk or of=/dev/sda2 for the second partition on the first hard disk). If this is not possible, a normal file in the file system (such as using of=/root/testdatei1GB) can be written. The write performance achieved thereby will be a little slower (because metadata will also be written to the file system).

Important: When writing to a device (such as /dev/sda), the data stored there will be lost. For that reason, you should only use empty RAID arrays, hard disks or partitions.

Note:

  • When using if=/dev/zero and bs=1G, Linux will need 1GB of free space in RAM. If your test system does not have sufficient RAM available, use a smaller parameter for bs (such as 512MB).
  • In order to get results closer to real-life, we recommend performing the tests described several times (three to ten times, for example). By doing so, you can quickly detect outliers. Such outliers can include cron jobs, interrupts or general conditions due to parallel processing, which can all briefly affect performance. An extreme example, which clarifies this issue, would be the parallel execution of updatedb by a cron job.

Laptop Example

In this example, the test data will be written to /dev/sda2. The test system (a Thinkpad T43 Type 2668-4GG) had 1.5 GByte of RAM and a Fujitsu MHT2060AH hard disk rotating at 5,400 rpm.

Laptop Throughput (Streaming I/O)

One gigabyte was written for the test, first with the cache activated (hdparm -W1 /dev/sda):

[email protected] ~ # dd if=/dev/zero of=/dev/sda2 bs=1G count=1 oflag=direct
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB) copied, 32.474 s, 33.1 MB/s
[email protected] ~ #

Then, with the cache deactivated (hdparm -W0 /dev/sda):

[email protected] ~ # dd if=/dev/zero of=/dev/sda2 bs=1G count=1 oflag=direct
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB) copied, 123.37 s, 8.7 MB/s
[email protected] ~ #

Laptop Latency

In this test, 512 bytes were written one thousand times, first with the cache activated (hdparm -W1 /dev/sda):

[email protected] ~ # dd if=/dev/zero of=/dev/sda2 bs=512 count=1000 oflag=direct
1000+0 records in
1000+0 records out
512000 bytes (512 kB) copied, 0.36084 s, 1.4 MB/s
[email protected] ~ #

Then, with the cache deactivated (hdparm -W0 /dev/sda): One thousand accesses required 11.18 seconds, meaning one access took 11.18 ms.

[email protected] ~ # dd if=/dev/zero of=/dev/sda2 bs=512 count=1000 oflag=direct
1000+0 records in
1000+0 records out
512000 bytes (512 kB) copied, 11.1865 s, 45.8 kB/s
[email protected] ~ #

Server with RAID10 Example

In this example, the test data was written to an empty partition. The test system was an 2HE Intel Dual-CPU SC823 Server with six 147 GB SAS Fujitsu MBA3147RC (15,000 rpm) hard disks and an Adaptec 5805 RAID controller with the cache activated and a BBU.

Server Throughput (Streaming I/O)

One gigabyte was written for the test:

test-sles10sp2:~ # dd if=/dev/zero of=/dev/sda6 bs=1G count=1 oflag=dsync
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB) copied, 5.11273 seconds, 210 MB/s
test-sles10sp2:~

Server Latency

In this test, 512 bytes were written one thousand times. Thereby, the 0.084 seconds that were measured for one thousand accesses corresponded to precisely 0.084 ms for each access. This value is so low because of the RAID controller’s cache:

test-sles10sp2:~ # dd if=/dev/zero of=/dev/sda6 bs=512 count=1000 oflag=dsync
1000+0 records in
1000+0 records out
512000 bytes (512 kB) copied, 0.083902 seconds, 6.1 MB/s
test-sles10sp2:~ #
时间: 2024-10-27 18:52:50

[linux]linuxI/O测试的方法之dd的相关文章

Linux 文件系统错误的修复方法 ddrescue替代dd的恢复软件 备用超级块

Linux 文件系统错误的修复方法  ddrescue替代dd的恢复软件  备用超级块 最近处理的一件 linux 服务器断电导致文件系统启动后文件系统不可读写,数据不可用的案例,现总结下 Linux 文件系统错误的修复方法.EXT3-fs error (device hda3) in start_transaction: Journal has abortedIf your system abruptly loses power, or if a RAID card is beginning

Linux压缩/解压缩命令使用方法

compress 命令 [[email protected] ~]# compress [-dcr] 文件或目录 参数: -d :用来解压缩的参数 -r :可以连同目录下的文件也同时给予压缩[此参数慎用比较危险] -c :将压缩资料输出成为 standard output (输出到屏幕) 范例: 范例一:将 /etc/install.log 复制到 /tmp ,并加以压缩 [[email protected] ~]# cd /tmp [[email protected] tmp]# cp /et

Linux自动登陆的设置方法

前些天为了实现Linux自动登陆的方法,在网上查了很多资料,发现有不少方法,但网上有些方法的讲解不是特别清楚,或者已经过时.因此,特意整理了一下Linux自动登陆的设置方法.本文的测试环境为Centos 5.5. 1.设置GDMGDM是GNOME显示管理器,通过设置其配置文件/etc/gdm/custom.conf可以设置帐号自动登陆.设置方法如下:在/etc/gdm/custom.conf文件中添加以下内容[daemon]AutomaticLogin=usernameAutomaticLogi

linux中select的使用方法

fd_set是一组文件描述符(fd,file descriptor)的集合,它用一位来表示一个fd. 系统提供了4个宏对描述符集进行操作: #include <sys/select.h>#include <sys/time.h> //设置文件描述符集fdset中对应于文件描述符fd的位(设置为1)void FD_SET(int fd, fd_set *fdset); //清除文件描述符集fdset中对应于文件描述符fd的位(设置为0)void FD_CLR(int fd, fd_s

linux利用sendmail发送邮件的方法

linux利用sendmail发送邮件, 方法1 安装sendmail即可使用, mail -s "test" [email protected] <content.txt bin/mail会默认使用本地sendmail发送邮件,这样要求本地的机器必须安装和启动Sendmail服务,配置非常麻烦,而且会带来不必要的资源占用. 方法2.利用外部的smpt服务器 而通过修改配置文件可以使用外部SMTP服务器,可以达到不使用sendmail而用外部的smtp服务器发送邮件的目的: 修改

Linux系统下安装phpmyadmin方法

phpmyadmin下载地址:不要分,赶紧去下载吧!http://download.csdn.net/detail/u011986449/7429799 1.找到 /libraries/config.default.php文件(config.default.php复制到phpmyadmin目录下,然后更名为config.inc.php),该文件有如下项目(2-8)须自行配置,windows用写字板(不要用记事本,这是UTF8编码)进行编辑,在linux下直接用vim编辑. 2.查找 $cfg['

linux忘记mysql密码找回方法

linux忘记mysql教程密码找回方法 今天我们主要是讲一下关于linux忘记mysql密码处理方法,下面提供了5种linux忘记mysql密码找回方法哦.    方法一: # /etc/init.d/mysql stop # mysqld_safe --user=mysql -    linux忘记mysql教程密码找回方法 今天我们主要是讲一下关于linux忘记mysql密码处理方法,下面提供了5种linux忘记mysql密码找回方法哦.    方法一:    # /etc/init.d/

Linux下清空缓冲区的方法

Linux下清空缓冲区的方法 C标准规定fflush()函数是用来刷新输出(stdout)缓存的.对于输入(stdin),它是没有定义的.但是有些编译器也定义了fflush( stdin )的实现,比如微软的VC.其它编译器是否也定义了fflush( stdin )的实现应当查找它的手册. GCC编译器没有定义它的实现,所以不能使用fflush(stdin)来刷新输入缓存.对于没有定义fflush(stdin)的编译器,可以使用fgets()函数来代替它(比用getchar().scanf()等

linux中安装samba的方法以及注意事项

linux中安装软件的方法有很多种:1. 用rpm包直接进行安装(rpm -ivh package):2.yum安装:3.apt-get等. 如果能够联网,用apt-get是最简单的方法.但如果无法联网怎么办呢? 如果采用方法1进行安装,需要下载安装所需包及其依赖包:如果版本不符,还需要不断验证对应可行的版本,较为繁琐复杂,因此不太建议采用该方案. 因此,这里采用了yum进行安装. 使用yum安装,也需要有一个可靠的源,可在/etc/yum.repos.d/中新建myyum.repo文件,并写入