How to properly use 'dd' to benchmark the write speed of your disk?
来源:互联网 发布:lolita slave toy知乎 编辑:程序博客网 时间:2024/05/16 00:34
This article is written to address sometimes incorrect usage of the “dd” program to measure disk write performance on a VPS by some visitors of the lowendbox.com website, and is originally based on this question and my answer to it.
Initially published on 2010-11-29.
Q: What is the difference between the following?
dd bs=1M count=128 if=/dev/zero of=test
dd bs=1M count=128 if=/dev/zero of=test; sync
dd bs=1M count=128 if=/dev/zero of=test conv=fdatasync
dd bs=1M count=128 if=/dev/zero of=test oflag=dsync
A: The difference is in handling of the write cache in RAM:
dd bs=1M count=128 if=/dev/zero of=test
The default behaviour ofdd
is to not “sync” (i.e. not ask the OS to completely write the data to disk beforedd
exiting). The above command will just commit your 128 MB of data into a RAM buffer (write cache) – this will be really fast and it will show you the hugely inflated benchmark result right away. However, the server in the background is still busy, continuing to write out data from the RAM cache to disk.dd bs=1M count=128 if=/dev/zero of=test; sync
Absolutely identical to the previous case, as anyone who understands how *nix shell works should surely know that adding a; sync
does not affect the operation of previous command in any way, because it is executed independently, after the first command completes. So your (wrong) MB/sec value is already printed on screen while thatsync
is only preparing to be executed.dd bs=1M count=128 if=/dev/zero of=test conv=fdatasync
This tellsdd
to require a complete “sync” once, right before it exits. So it commits the whole 128 MB of data, then tells the operating system: “OK, now ensure this is completely on disk”, only then measures the total time it took to do all that and calculates the benchmark result.dd bs=1M count=128 if=/dev/zero of=test oflag=dsync
Heredd
will ask for completely synchronous output to disk, i.e. ensure that its write requests don’t even return until the submitted data is on disk. In the above example, this will mean sync'ing once per megabyte, or 128 times in total. It would probably be the slowest mode, as the write cache is basically unused at all in this case.
Which one do you suggest?
dd bs=1M count=128 if=/dev/zero of=test conv=fdatasync
This behaviour is perhaps the closest to the way real-world tasks behave. If your server or VPS is really fast and the above test completes in a second or less, try increasing the count=
number to 1024 or so, to get a more accurate averaged result.
原文:http://romanrm.ru/en/dd-benchmark
- How to properly use 'dd' to benchmark the write speed of your disk?
- how to write your annotation types and make use of built-in annotations to control their behavior
- How to use the function of assembly.
- How to use your GemFile
- 5 Free Tools to Test and Benchmark Your Network Speed
- NDoc: How to Make Good Use of Your XML Comments?
- NDoc: How to Make Good Use of Your XML Comments?
- NDoc: How to Make Good Use of Your XML Comments?
- How to Use ADE to Get Benchmark on Linux
- the method to speed up your app
- How to write your own custom Form
- How to speed up the MV refresh
- How to Spend the First 10 Minutes of Your Day
- How to download Bing maps to your hard disk
- How to use Events in the Context of C#
- How to use "man" effectively in the development of Linux
- How to use the pointer of function in a class?
- How to use the CAknWaitDialog
- On Amazon EC2's Underlying Architecture
- Amazon EBS 特性、故障和设计
- javascript 事件代理初探
- Web自动化测试工具——Selenium IDE
- 一个诡异的时间问题追查[转]
- How to properly use 'dd' to benchmark the write speed of your disk?
- xm migrate源码分析
- Linux进程管理(1)
- Linux进程管理(2)
- realloc理解
- 查看一个进程打开了哪些文件的命令
- linux kernel中的链表
- Xen Memory Management
- 数组乘积--求除自身外,其它数的乘积并放到result数组相应的位置