<?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/"
	>

<channel>
	<title>dasz.at - Benutzbare Technologie &#187; Benchmarking</title>
	<atom:link href="http://dasz.at/index.php/category/benchmarking/feed/" rel="self" type="application/rss+xml" />
	<link>http://dasz.at</link>
	<description>Benutzbare Technologie</description>
	<lastBuildDate>Wed, 07 Jul 2010 06:54:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Minor note on &#8216;dd&#8217; write performance</title>
		<link>http://dasz.at/index.php/2009/09/minor-note-on-dd-write-performance/</link>
		<comments>http://dasz.at/index.php/2009/09/minor-note-on-dd-write-performance/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 22:12:31 +0000</pubDate>
		<dc:creator>David Schmitt</dc:creator>
				<category><![CDATA[Benchmarking]]></category>
		<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://dasz.at/index.php/2009/09/minor-note-on-dd-write-performance/</guid>
		<description><![CDATA[Today I was cleaning out some old logical volumes. Since they resided on rented harddisks, I chose to overwrite them with zeroes to avoid leaving data tracks on someone else&#8217;s disks. The first thing that came to my mind was this:

dd if=/dev/zero of=/dev/vg/lv


Since I had ten logical volumes, I also ran ten instances of dd [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was cleaning out some old logical volumes. Since they resided on rented harddisks, I chose to overwrite them with zeroes to avoid leaving data tracks on someone else&#8217;s disks. The first thing that came to my mind was this:</p>
<pre>
dd if=/dev/zero of=/dev/vg/lv
</pre>
<p><span id="more-93"></span></p>
<p>Since I had ten logical volumes, I also ran ten instances of <a href="http://linux.die.net/man/1/dd">dd</a> in parallel. They were on a RAID and I was decommissioning the server, so I didn&#8217;t really care about performance. Speaking of which, I like to spy on running processes, call my a techno-voyeur if you want!</p>
<p>Anyways, <a href="http://linux.die.net/man/8/vmstat">vmstat</a> was telling me that the system was chugging along nicely, reading(sic!) and writing approximately 16MB/s each. Something was clearly wrong. Note the &#8220;bi&#8221; and &#8220;bo&#8221; columns, denoting kB/s read and written:</p>
<pre>
david@hetz:~$ vmstat 10
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
[...]
 0 12   6416 270676 1601220   9628    0    0 16628 16553 4481 7638  1 21 26 52
</pre>
<p>I had forgotten to specify the <a href="http://en.wikipedia.org/wiki/Block_%28data_storage%29">block</a> size which dd should use to make the transfer. And if the program is writing the zeroes one by one into the target file, the destination has to be read before it is modified, since the <a href="http://en.wikipedia.org/wiki/Linux_kernel">kernel</a> cannot (and should not!) guess that the rest of the block (which is all we&#8217;re talking about at this stage) will be overwritten too.</p>
<p>To test my hypotheses, I restarted the processes and told dd to use nice 1MB sized blocks. I had ten threads to keep the hardware busy, so that shouldn&#8217;t make any problems.</p>
<pre>
dd if=/dev/zero of=/dev/vg/lv bs=1M
</pre>
<p>Really, in this configuration, the system stabilized around a nice 55MB/s writes. The kernel was able to recognize that the 1MB sized writes would cover complete blocks and that their content would be overwritten. No need to load them beforehand:</p>
<pre>
david@hetz:~$ vmstat 10
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
[...]
 0 12   6416  16308 1749688   5312    0    0     0 55644  551 1576  0 23  1 76
</pre>
<p>While I was waiting for the last process to finish, I noticed that throughput had risen to 60MB/s:</p>
<pre>
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
[...]
 1  3   6416  15336 1750492   6088    0    0      4 62892  545  232  0 28 32 39
</pre>
<p>To summarize: having only one process running is ~10% faster than having ten processes running and using a non-trivial blocksize is more than three times faster than specifying none at all.</p>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2009/09/minor-note-on-dd-write-performance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XCache</title>
		<link>http://dasz.at/index.php/2009/08/xcache-speeds-up-php/</link>
		<comments>http://dasz.at/index.php/2009/08/xcache-speeds-up-php/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 08:46:13 +0000</pubDate>
		<dc:creator>David Schmitt</dc:creator>
				<category><![CDATA[Benchmarking]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://dasz.at/index.php/2009/08/xcache-speeds-up-php/</guid>
		<description><![CDATA[Installed XCache a few days ago. Traded 64MB RAM for instant PHP speed goodness. Sometimes you can have your cake AND eat it.  
]]></description>
			<content:encoded><![CDATA[<p>Installed <a href="http://xcache.lighttpd.net/">XCache</a> a few days ago. Traded 64MB RAM for instant PHP speed goodness. Sometimes you can have your cake AND eat it. <img src='http://dasz.at/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2009/08/xcache-speeds-up-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>.Net microbenchmarking</title>
		<link>http://dasz.at/index.php/2009/01/net-microbenchmarking/</link>
		<comments>http://dasz.at/index.php/2009/01/net-microbenchmarking/#comments</comments>
		<pubDate>Sat, 31 Jan 2009 17:05:41 +0000</pubDate>
		<dc:creator>David Schmitt</dc:creator>
				<category><![CDATA[Benchmarking]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[StackOverflow]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://dasz.at/index.php/2009/01/net-microbenchmarking/</guid>
		<description><![CDATA[In a recent discussion on StackOverflow about performance of arrays vs. lists and for vs. foreach, Jon Skeet created a little microbenchmarking framework and posted his detailed findings on his blog.
First, my local results of the benchmark. I compiled them as Release under VS 2008 SP1. Running without debugging on a Q6600@2.40GHz, .NET 3.5 SP1. [...]]]></description>
			<content:encoded><![CDATA[<p>In a recent discussion on <a href="http://stackoverflow.com/">StackOverflow</a> about performance of <a href="http://stackoverflow.com/questions/454916/performance-of-arrays-vs-lists">arrays vs. lists</a> and <a href="http://stackoverflow.com/questions/472191/c-for-vs-foreach">for vs. foreach</a>, <a href="http://stackoverflow.com/users/22656/jon-skeet">Jon Skeet</a> created a little microbenchmarking framework and posted <a href="http://msmvps.com/blogs/jon_skeet/archive/2009/01/29/for-vs-foreach-on-arrays-and-lists.aspx">his detailed findings on his blog</a>.</p>
<p>First, my local results of the benchmark. I compiled them as Release under VS 2008 SP1. Running without debugging on a Q6600@2.40GHz, .NET 3.5 SP1. They pretty exactly match Jon&#8217;s numbers so I won&#8217;t duplicate them here, but you can find them in the page&#8217;s source.</p>
<p><!--><br />
============ Doubles ============<br />
============ double[] ============<br />
For                1,00<br />
ForHoistLength     1,00<br />
ForEach            1,00<br />
IEnumerableForEach 8,28<br />
Enumerable.Sum     8,27</p>
<p>============ List<double> ============<br />
For                 2,00<br />
ForHoistLength      1,43<br />
ForEach             6,02<br />
IEnumerableForEach 14,03<br />
Enumerable.Sum     14,04</p>
<p>============ Ints ============<br />
============ int[] ============<br />
For                 1,00<br />
ForHoistLength      2,06<br />
ForEach             1,38<br />
IEnumerableForEach 15,46<br />
Enumerable.Sum     16,06</p>
<p>============ List<int> ============<br />
For                 2,84<br />
ForHoistLength      3,53<br />
ForEach             4,86<br />
IEnumerableForEach 26,33<br />
Enumerable.Sum     26,33</p>
<p><!--></p>
<p>Out of interest how the differences are when there is more to do in the loop&#8217;s body, I added a test suite that formatted the sum as string and appended it to a <code>StringBuilder</code>:</p>
<p><span id="more-74"></span></p>
<pre class="brush: c#; ">

var sbArraySuite = TestSuite.Create(&quot;build Strings from Array&quot;, doubleArray, String.Join(&quot;&quot;, doubleArray.Select(d =&gt; String.Format(&quot;{0:0.00}\n&quot;, d)).ToArray()))
    .Add(input =&gt;
    {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i &lt; input.Length; i++)
            sb.AppendFormat(&quot;{0:0.00}\n&quot;, input[i]);
        return sb.ToString();
    }, &quot;For&quot;)
    .Add(input =&gt;
    {
        StringBuilder sb = new StringBuilder(); int length = input.Length;
        for (int i = 0; i &lt; length; i++)
            sb.AppendFormat(&quot;{0:0.00}\n&quot;, input[i]);
        return sb.ToString();
    }, &quot;ForHoistLength&quot;)
    .Add(input =&gt;
    {
        StringBuilder sb = new StringBuilder();
        foreach (double d in input)
            sb.AppendFormat(&quot;{0:0.00}\n&quot;, d);
        return sb.ToString();
    }, &quot;ForEach&quot;)
    .Add(IEnumerableForEachToString)
    .RunTests();

    ...

    static string IEnumerableForEachToString(IEnumerable&lt;double&gt; input)
    {
        StringBuilder sb = new StringBuilder();
        foreach (double d in input)
        {
            sb.AppendFormat(&quot;{0:0.00}\n&quot;, d);
        }
        return sb.ToString();
    }
</pre>
<p>Which gives these results:</p>
<pre>
============ build Strings from Array ============
For                        1,01
ForHoistLength             1,01
ForEach                    1,01
IEnumerableForEachToString 1,03

============ build Strings from List ============
For                        1,00
ForHoistLength             1,00
ForEach                    1,02
IEnumerableForEachToString 1,05
</pre>
<p>Suddenly the relative differences between for/foreach and array/list collapse to 1-5%. Which confirms my intuition that algorithms usually matter much more and such optimisations are quite useless. At least we all had good fun on a saturday <img src='http://dasz.at/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2009/01/net-microbenchmarking/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
