Linux I/O Performance Tests using dd
来源:互联网 发布:沐足软件 编辑:程序博客网 时间:2024/05/16 09:30
Under Linux, the dd
command can be used for simple I/O performance measurements. This article will provide valuable information about which parameters should be used.
Contents
[hide]- 1 Basics
- 2 Measuring Write Performance
- 2.1 Laptop Example
- 2.1.1 Laptop Throughput (Streaming I/O)
- 2.1.2 Laptop Latency
- 2.2 Server with RAID10 Example
- 2.2.1 Server Throughput (Streaming I/O)
- 2.2.2 Server Latency
- 2.1 Laptop Example
- 3 References
Basics
dd
can be used for simplified copying of data at the low level.[1] In doing this, device files are often access directly. Since additional queries do not arrive while the device is being accessed, erroneous usage of dd
can quickly lead to data loss. We absolutely recommend performing the steps described below on test systems. If dd
is used incorrectly, data loss will be the result.
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 detectoutliers. 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):
root@grml ~ # dd if=/dev/zero of=/dev/sda2 bs=1G count=1 oflag=direct1+0 records in1+0 records out1073741824 bytes (1.1 GB) copied, 32.474 s, 33.1 MB/sroot@grml ~ #
Then, with the cache deactivated (hdparm -W0 /dev/sda):
root@grml ~ # dd if=/dev/zero of=/dev/sda2 bs=1G count=1 oflag=direct 1+0 records in1+0 records out1073741824 bytes (1.1 GB) copied, 123.37 s, 8.7 MB/sroot@grml ~ #
Laptop Latency
In this test, 512 bytes were written one thousand times, first with the cache activated (hdparm -W1 /dev/sda):
root@grml ~ # dd if=/dev/zero of=/dev/sda2 bs=512 count=1000 oflag=direct1000+0 records in1000+0 records out512000 bytes (512 kB) copied, 0.36084 s, 1.4 MB/sroot@grml ~ #
Then, with the cache deactivated (hdparm -W0 /dev/sda): One thousand accesses required 11.18 seconds, meaning one access took 11.18 ms.
root@grml ~ # dd if=/dev/zero of=/dev/sda2 bs=512 count=1000 oflag=direct1000+0 records in1000+0 records out512000 bytes (512 kB) copied, 11.1865 s, 45.8 kB/sroot@grml ~ #
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=dsync1+0 records in1+0 records out1073741824 bytes (1.1 GB) copied, 5.11273 seconds, 210 MB/stest-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=dsync1000+0 records in1000+0 records out512000 bytes (512 kB) copied, 0.083902 seconds, 6.1 MB/stest-sles10sp2:~ #
References
- ↑ Dd (Unix) (en.wikipedia.org)
- ↑ /dev/zero (en.wikipedia.org)
Author: Werner Fischer
- Linux I/O Performance Tests using dd
- Boost application performance using asynchronous I/O
- MySQL Performance: Linux I/O
- Analyzing I/O performance in Linux
- ANALYZING I/O PERFORMANCE IN LINUX
- Boost application performance using asynchronous I/O-ref
- Analyzing I/O performance
- Tuning I/O Performance
- Pin I/O performance
- [转] Linux System and Performance Monitoring(I/O篇)
- Linux System and Performance Monitoring(I/O篇)
- Linux System and Performance Monitoring(I/O篇)
- Linux I/O performance monitoring utility —— I/O 性能检测软件
- Improving (network) I/O performance
- Tuning Java I/O Performance
- Measuring & Optimizing I/O Performance
- Weblogic启动包错<Error> <Socket> <BEA-000438> <Unable to load performance pack. Using Java I/O instead.
- [Java Performance] 缓冲I/O(Buffered I/O)
- Android 实用工具Hierarchy Viewer实战
- android-UI组件(二):TextView及其子类
- 简单工厂模式
- memcpy和memmove的区别与联系
- POJ 2395
- Linux I/O Performance Tests using dd
- Java类加载机制
- sicily 1935. 二叉树重建
- POJ 2385 Apple Catching (DP)
- 中断处理(中断向量寄存器)
- DatePicker的使用(三):初始化
- U3D-隐性的局部变量
- 深入理解计算机系统 - 引言
- mac os x 10.8 安装python-mysqldb