<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>blog@insidesystems.net: What did I do wrong?</title>
    <link>http://blog.insidesystems.net/articles/2007/04/09/what-did-i-do-wrong</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>What did I do wrong?</title>
      <description>&lt;p&gt;I&amp;#8217;m hoping that somebody will look at this and say &amp;#8220;hey, dummy, you did this all wrong.&amp;#8221;  I&amp;#8217;m hoping that, because the results are shocking.&lt;/p&gt;


	&lt;p&gt;There have been a buzz about FreeBSD&amp;#8217;s &lt;span class="caps"&gt;SMP&lt;/span&gt; performance compared to Linux&amp;#8217;s, particularly a particular 8-core &lt;span class="caps"&gt;SMP&lt;/span&gt; test, using FreeBSD 7.0, sysbench, and mysql.  A number of people mentioned that there were known problems with this test and PostgreSQL, so I decided to see how bad the problems were.&lt;/p&gt;&lt;p&gt;The results are so shocking, that my first thought was that I must have done something wrong.&lt;/p&gt;


	&lt;p&gt;The hardware:&lt;/p&gt;


	&lt;p&gt;Machine 1:&lt;br/&gt;
&lt;span class="caps"&gt;HP DL360 G5&lt;/span&gt;&lt;br/&gt;
1 5140 (dual core) 2.33 GHz (1333 &lt;span class="caps"&gt;FSB&lt;/span&gt;) Xeon&lt;br/&gt;
4 &lt;span class="caps"&gt;GB RAM&lt;/span&gt;&lt;br/&gt;
2 15K &lt;span class="caps"&gt;RPM SAS&lt;/span&gt; hard drives, running as mirrors through an e400i drive array&lt;/p&gt;


	&lt;p&gt;Machine 2:&lt;br/&gt;
&lt;span class="caps"&gt;HP DL360 G5&lt;/span&gt;&lt;br/&gt;
2 &lt;span class="caps"&gt;E5335&lt;/span&gt; (quad core) 2.33 GHz (1333 &lt;span class="caps"&gt;FSB&lt;/span&gt;) Xeons&lt;br/&gt;
10 &lt;span class="caps"&gt;GB RAM&lt;/span&gt;&lt;br/&gt;
2 10K &lt;span class="caps"&gt;RPM SAS&lt;/span&gt; hard drives, running as mirrors through an e400i drive array&lt;/p&gt;


	&lt;p&gt;Operating System:
Both machines are running FreeBSD 6.2-p3.  After all, I wanted to see what performance levels to expect with production-quality software, not the 7.0 sweetness.&lt;/p&gt;


	&lt;p&gt;Kernel:
Both are running identically configured &lt;span class="caps"&gt;SMP&lt;/span&gt;-enabled amd64 kernels.&lt;/p&gt;


sysctl.conf:  both have the following
&lt;code&gt;
&lt;pre&gt;
kern.ipc.shmmax=2147483647
kern.ipc.shmall=524288
kern.ipc.semmsl=512
kern.ipc.semmap=256
kern.ipc.somaxconn=2048
kern.maxfiles=65536
vfs.read_max=32
&lt;/pre&gt;
&lt;/code&gt;

loader.conf: both have the following
&lt;code&gt;
&lt;pre&gt;
kern.ipc.semmni=256
kern.ipc.semmns=2048
&lt;/pre&gt;
&lt;/code&gt;

postgresql.conf: both have the following settings changed
&lt;code&gt;
&lt;pre&gt;
shared_buffers = 1GB                 
work_mem = 64MB
maintenance_work_mem = 32MB
max_fsm_pages = 204800   
random_page_cost = 3.0
effective_cache_size = 512MB
update_process_title = off
&lt;/pre&gt;
&lt;/code&gt;

	&lt;p&gt;Both drive arrays are partitioned identically, and postgres was installed as the only running application in each case.&lt;/p&gt;


The test was run as follows:
&lt;code&gt;
&lt;pre&gt;
sysbench --num-threads=${i} --test=oltp --pgsql-user=bench --pgsql-db=bench --db-driver=pgsql --max-time=120 --max-requests=0 --oltp-read-only=on run
&lt;/pre&gt;
&lt;/code&gt;

	&lt;p&gt;And yet here are the results:&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://blog.insidesystems.net/files/sysctl-pgsq-amd64-wtf.png"&gt;&lt;/p&gt;


	&lt;p&gt;Yes, the 8-core, 10GB machine is massively slower than the 2-core 4GB machine.&lt;/p&gt;


	&lt;p&gt;This can&amp;#8217;t be right, can it?&lt;/p&gt;


Followup: I ran this single-cpu test:
&lt;code&gt;
&lt;pre&gt;
openssl speed rsa
&lt;/pre&gt;
&lt;/code&gt;

1&amp;#215;2-Core 2.33GHz 5140 Xeon
&lt;code&gt;
&lt;pre&gt;
                  sign    verify    sign/s verify/s
rsa  512 bits   0.0003s   0.0000s   3905.9  45028.8
rsa 1024 bits   0.0009s   0.0001s   1164.6  18787.2
rsa 2048 bits   0.0049s   0.0002s    205.2   6332.2
rsa 4096 bits   0.0320s   0.0005s     31.2   1917.9

&lt;/pre&gt;
&lt;/code&gt;

2&amp;#215;4-Core 2.33 GHz &lt;span class="caps"&gt;E5335&lt;/span&gt; Xeon
&lt;code&gt;
&lt;pre&gt;
rsa  512 bits   0.0003s   0.0000s   3381.1  38972.0
rsa 1024 bits   0.0010s   0.0001s   1003.5  15991.7
rsa 2048 bits   0.0057s   0.0002s    176.7   5481.7
rsa 4096 bits   0.0373s   0.0006s     26.8   1638.6
&lt;/pre&gt;
&lt;/code&gt;

	&lt;p&gt;I wanted to see if this was simply one algorithm, or if other algorithms showed the same sort of slowdown, so I ran the following:&lt;/p&gt;


&lt;code&gt;
&lt;pre&gt;
openssl speed md5 sha1 aes-256-cbc
&lt;/pre&gt;
&lt;/code&gt;

The 2-core machine:
&lt;code&gt;
&lt;pre&gt;
The 'numbers' are in 1000s of bytes per second processed.
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes
md5              14172.75k    45816.42k   114118.73k   182293.03k   220175.36k
sha1             14901.45k    42795.69k    97387.27k   143547.69k   166264.67k
aes-256 cbc      91518.54k    94159.65k    93817.92k    92696.25k    93907.24k
&lt;/pre&gt;
&lt;/code&gt;

The 8-core machine:
&lt;code&gt;
&lt;pre&gt;
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes
md5              12305.58k    39149.96k    97745.88k   155771.63k   188252.02k
sha1             12740.06k    36648.90k    83318.76k   122733.05k   142119.67k
aes-256 cbc      78109.56k    80589.95k    81222.08k    81406.47k    81401.94k
&lt;/pre&gt;
&lt;/code&gt;

	&lt;p&gt;The 8-core is a little slower than the 2-core again, but not by the enormous levels we see on the pgsql sysbench.&lt;/p&gt;


	&lt;p&gt;When running &lt;span class="caps"&gt;RSA&lt;/span&gt; across multiple threads, the results are closer to what one would expect.  The command I used to do this:&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
openssl speed rsa -multi N
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;&lt;img src="http://blog.insidesystems.net/files/amd64-normal.png"&gt;&lt;/p&gt;


	&lt;p&gt;And now I&amp;#8217;m left with the question:  Did I screw something up, or is this what Kris Kennaway was talking about when he wrote &lt;a href="http://lists.freebsd.org/pipermail/freebsd-performance/2007-February/002510.html"&gt;this message&lt;/a&gt;?&lt;/p&gt;


	&lt;p&gt;I must admit, that while I expected the performance to fall off, it never occurred to me that an 8-core system could be slower than a 2-core system right out of the gate.&lt;/p&gt;</description>
      <pubDate>Mon, 09 Apr 2007 21:09:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:bea24221-58d2-4935-a45f-d92dfc38ca49</guid>
      <author>Kevin Way</author>
      <link>http://blog.insidesystems.net/articles/2007/04/09/what-did-i-do-wrong</link>
      <category>Databases</category>
      <category>FreeBSD</category>
      <category>System Administration</category>
      <category>PostgreSQL</category>
    </item>
    <item>
      <title>"What did I do wrong?" by Kevin Way</title>
      <description>&lt;p&gt;Well, I wouldn&amp;#8217;t buy one for use as a PostgreSQL 8.2.3 database, running on FreeBSD 6.2, at least.  Not unless you hate money.&lt;/p&gt;</description>
      <pubDate>Mon, 09 Apr 2007 23:48:34 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:d55cfe46-428c-424f-a943-bd229249fc6f</guid>
      <link>http://blog.insidesystems.net/articles/2007/04/09/what-did-i-do-wrong#comment-28</link>
    </item>
    <item>
      <title>"What did I do wrong?" by ddavisson@alpineinternet.com</title>
      <description>&lt;p&gt;Interesting.  I stumbled across your blog, then this post, and I will think twice about getting that dual quad core.&lt;/p&gt;</description>
      <pubDate>Mon, 09 Apr 2007 22:26:05 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:d06f0e96-72cf-4ff2-83a5-db3d0157bf69</guid>
      <link>http://blog.insidesystems.net/articles/2007/04/09/what-did-i-do-wrong#comment-27</link>
    </item>
  </channel>
</rss>
