<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>/contrib/famzah &#187; disk write performance benchmark</title>
	<atom:link href="http://blog.famzah.net/tag/disk-write-performance-benchmark/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.famzah.net</link>
	<description>Enthusiasm never stops</description>
	<lastBuildDate>Thu, 02 Feb 2012 15:36:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='blog.famzah.net' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>/contrib/famzah &#187; disk write performance benchmark</title>
		<link>http://blog.famzah.net</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.famzah.net/osd.xml" title="/contrib/famzah" />
	<atom:link rel='hub' href='http://blog.famzah.net/?pushpress=hub'/>
		<item>
		<title>&#8220;dd&#8221; sequential write performance tests on a raw block device may be incorrect</title>
		<link>http://blog.famzah.net/2010/02/05/dd-sequential-write-performance-tests-on-a-raw-block-device-may-be-incorrect/</link>
		<comments>http://blog.famzah.net/2010/02/05/dd-sequential-write-performance-tests-on-a-raw-block-device-may-be-incorrect/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 12:23:36 +0000</pubDate>
		<dc:creator>Ivan Zahariev</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[block device block size]]></category>
		<category><![CDATA[dd benchmark]]></category>
		<category><![CDATA[disk write performance benchmark]]></category>
		<category><![CDATA[iostat]]></category>
		<category><![CDATA[linux performance]]></category>

		<guid isPermaLink="false">http://blog.famzah.net/?p=407</guid>
		<description><![CDATA[&#8230;if you use the inappropriate bytes size (bs) option. See the man page of dd for details on this option. Hard disks have a typical block size of 512 bytes. LVM on the other hand creates its block devices with a block size of 4096 bytes. So it&#8217;s easy to get confused &#8211; even if [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.famzah.net&amp;blog=10109730&amp;post=407&amp;subd=famzah&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&#8230;if you use the inappropriate bytes size (bs) option. See the <a href="http://linux.die.net/man/1/dd">man page of dd</a> for details on this option.</p>
<p>Hard disks have a typical block size of 512 bytes. <a href="http://sourceware.org/lvm2/">LVM</a> on the other hand creates its block devices with a block size of 4096 bytes. So it&#8217;s easy to get confused &#8211; even if you know that disks should be tested with blocks of 512 bytes, you shouldn&#8217;t test LVM block devices with a 512-bytes but with a 4096-bytes block size.</p>
<p><u>What happens if you make a write performance test by writing directly on the raw block device and you use the wrong bytes size (bs) option?</u></p>
<p>If you look at the &#8220;<a href="http://linux.die.net/man/1/iostat">iostat</a>&#8221; statistics, they will show lots of read requests too, when you are only writing. This is not what is expected when you do <strong>only</strong> writing.<br />
The problem comes by the fact that when you are not using the proper block size for the raw block device, instead of writing whole blocks, you are writing partial blocks. This is however physically not possible &#8211; the block device can only write one <strong>whole</strong> block at a time. In order to update the data in only a part of a block, this block needs to be read back first, then modified with the new partial data in memory and finally written back as a whole block.</p>
<p>The <strong>total performance drop</strong> is about 3 times on the systems I tested. I&#8217;ve tested this on some hard disks and on an <a href="http://www.areca.com.tw/">Areca</a> RAID-6 volume.</p>
<p><u>So what&#8217;s the lesson here?</u></p>
<p>When you do sequential write performance tests with &#8220;dd&#8221; directly on the raw block device, make sure that you use the proper bytes size option, and verify that during the tests you see <strong>only</strong> write requests in the &#8220;<a href="http://linux.die.net/man/1/iostat">iostat</a>&#8221; statistics.</p>
<p><u>Physical hard disk example:</u></p>
<div class="sourcecode">
<pre class="brush: bash; light: true;">
# Here is a bad example for a hard disk device
dd if=/dev/zero of=/dev/sdb1 bs=256 count=5000000

# Here is the proper usage, because /dev/sda physical block size is 512 bytes
dd if=/dev/zero of=/dev/sdb1 bs=512 count=5000000 
</pre>
</div>
<p><u>LVM block device example:</u></p>
<div class="sourcecode">
<pre class="brush: bash; light: true;">
# Another bad example, this time for an LVM block device
dd if=/dev/zero of=/dev/sdb-vol/test bs=512 count=1000000

# Here is the proper usage, because the LVM block size is 4096 bytes
dd if=/dev/zero of=/dev/sdb-vol/test bs=4k count=1000000
</pre>
</div>
<p><u>Understanding the &#8220;<a href="http://linux.die.net/man/1/iostat">iostat</a>&#8221; output during a &#8220;dd&#8221; test:</u></p>
<p>Here is what &#8220;<a href="http://linux.die.net/man/1/iostat">iostat</a>&#8221; displays when you are <strong>not</strong> using the proper bytes size option (lots of read &#8220;r/s&#8221; and &#8220;rsec/s&#8221; requests):</p>
<div class="sourcecode">
<pre class="brush: plain; light: true; wrap-lines: false;">
Device:         rrqm/s   wrqm/s     r/s     w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util
sdb               0.00  5867.40 3573.20   46.40 28585.60 47310.40 20.97   110.38   30.61   0.28 100.00
sdb1              0.00     0.00    0.00    0.00     0.00     0.00 0.00     0.00    0.00   0.00   0.00
sdb2              0.00  5867.40 3572.80   46.40 28582.40 47310.40 20.97   110.38   30.61   0.28 100.00
dm-2              0.00     0.00 3572.80 5913.80 28582.40 47310.40 8.00 13850.92 1465.43   0.11 100.00 
</pre>
</div>
<p>Here is what it should display (no read &#8220;r/s&#8221; or &#8220;rsec/s&#8221; requests at all):</p>
<div class="sourcecode">
<pre class="brush: plain; light: true; wrap-lines: false;">
Device:         rrqm/s   wrqm/s     r/s     w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util
sdb               0.00 16510.00    0.00  128.60     0.00 131686.40 1024.00   107.82  840.32   7.78 100.00
sdb1              0.00     0.00    0.00    0.00     0.00     0.00 0.00     0.00    0.00   0.00   0.00
sdb2              0.00 16510.00    0.00  128.60     0.00 131686.40 1024.00   107.82  840.32   7.78 100.00
dm-2              0.00     0.00    0.00 16640.00     0.00 133120.00 8.00 13674.86  823.73   0.06 100.00 
</pre>
</div>
<p><u>How to be safe?</u></p>
<p>Fortunately, file systems are smart enough and pay attention to the block size of the block devices they were mounted on. So if you do a &#8220;<a href="http://linux.die.net/man/1/dd">dd</a>&#8221; write performance test and write to a file, you should be fine. Though in this case there are some other complications like journaling, commit intervals, barriers, mount options, etc.</p>
<br />Filed under: <a href='http://blog.famzah.net/category/linux/'>Linux</a> Tagged: <a href='http://blog.famzah.net/tag/block-device-block-size/'>block device block size</a>, <a href='http://blog.famzah.net/tag/dd-benchmark/'>dd benchmark</a>, <a href='http://blog.famzah.net/tag/disk-write-performance-benchmark/'>disk write performance benchmark</a>, <a href='http://blog.famzah.net/tag/iostat/'>iostat</a>, <a href='http://blog.famzah.net/tag/linux/'>Linux</a>, <a href='http://blog.famzah.net/tag/linux-performance/'>linux performance</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/famzah.wordpress.com/407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/famzah.wordpress.com/407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/famzah.wordpress.com/407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/famzah.wordpress.com/407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/famzah.wordpress.com/407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/famzah.wordpress.com/407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/famzah.wordpress.com/407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/famzah.wordpress.com/407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/famzah.wordpress.com/407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/famzah.wordpress.com/407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/famzah.wordpress.com/407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/famzah.wordpress.com/407/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/famzah.wordpress.com/407/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/famzah.wordpress.com/407/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.famzah.net&amp;blog=10109730&amp;post=407&amp;subd=famzah&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.famzah.net/2010/02/05/dd-sequential-write-performance-tests-on-a-raw-block-device-may-be-incorrect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e354dbace6659e6cfc6ec6f01d7d962d?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">famzah</media:title>
		</media:content>
	</item>
	</channel>
</rss>
