<?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>Journal de Jacques</title>
	<atom:link href="http://chester.id.au/feed/" rel="self" type="application/rss+xml" />
	<link>http://chester.id.au</link>
	<description>Stuff I write. Things that happen to me.</description>
	<lastBuildDate>Wed, 11 Aug 2010 03:17:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>An XCache &#8216;gotcha&#8217;</title>
		<link>http://chester.id.au/2010/08/11/an-xcache-gotcha/</link>
		<comments>http://chester.id.au/2010/08/11/an-xcache-gotcha/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 03:15:26 +0000</pubDate>
		<dc:creator>Jacques Chester</dc:creator>
				<category><![CDATA[Technical Notes]]></category>

		<guid isPermaLink="false">http://chester.id.au/?p=414</guid>
		<description><![CDATA[XCache is a PHP opcode cacher. This is good and well as it speeds up pageloads by removing PHP parsing overhead. On the downside, you must remember to restart your PHP processes after changing PHP files, as XCache doesn&#8217;t seem to perform stat()s on the files to check if they&#8217;ve been updated.]]></description>
			<content:encoded><![CDATA[<p><a href="http://xcache.lighttpd.net/">XCache</a> is a PHP opcode cacher. This is good and well as it speeds up pageloads by removing PHP parsing overhead. On the downside, you must remember to restart your PHP processes after changing PHP files, as XCache doesn&#8217;t seem to perform stat()s on the files to check if they&#8217;ve been updated.</p>
]]></content:encoded>
			<wfw:commentRss>http://chester.id.au/2010/08/11/an-xcache-gotcha/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Success</title>
		<link>http://chester.id.au/2010/08/08/success/</link>
		<comments>http://chester.id.au/2010/08/08/success/#comments</comments>
		<pubDate>Sun, 08 Aug 2010 09:11:06 +0000</pubDate>
		<dc:creator>Jacques Chester</dc:creator>
				<category><![CDATA[Diary]]></category>
		<category><![CDATA[Weightlifting]]></category>

		<guid isPermaLink="false">http://chester.id.au/?p=407</guid>
		<description><![CDATA[Today&#8217;s WWA Grand Prix #3 was a good day for yours truly. I won the gold for most-improved Sinclair and took second place for the premier cup. Snatch 90kg, Clean &#038; Jerk 130kg, total 220kg. Just as Jack Walls predicted. Update: Turns out I am the bronze medallist. Geish Hori is the silver medallist. A [...]]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s WWA Grand Prix #3 was a good day for yours truly. I won the gold for most-improved Sinclair and took second place for the premier cup. Snatch 90kg, Clean &#038; Jerk 130kg, total 220kg. Just as Jack Walls predicted.</p>
<p><strong>Update:</strong> Turns out I am the bronze medallist. Geish Hori is the silver medallist. A well-deserved win. Well done Geish!</p>
]]></content:encoded>
			<wfw:commentRss>http://chester.id.au/2010/08/08/success/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Brian&#8217;s Latest Comments doesn&#8217;t scale.</title>
		<link>http://chester.id.au/2010/08/06/brians-latest-comments-doesnt-scale/</link>
		<comments>http://chester.id.au/2010/08/06/brians-latest-comments-doesnt-scale/#comments</comments>
		<pubDate>Fri, 06 Aug 2010 06:10:37 +0000</pubDate>
		<dc:creator>Jacques Chester</dc:creator>
				<category><![CDATA[Technical Notes]]></category>

		<guid isPermaLink="false">http://chester.id.au/?p=399</guid>
		<description><![CDATA[Or, to be fair, MySQL 3.x is rubbish. But you knew that already. Most of the blogs on the Ozblogistan network use BLC. Recently, Larvatus Prodeo came on board and expected it to work for them too. But it simply hung without giving much in the way of error message. I pottered around with it [...]]]></description>
			<content:encoded><![CDATA[<p>Or, to be fair, MySQL 3.x is rubbish. But you knew that already.</p>
<p>Most of the blogs on the <a href="http://ozblogistan.com.au/">Ozblogistan</a> network use <a href="http://code.google.com/p/brianslatestcomments/">BLC</a>. Recently, <a href="http://larvatusprodeo.net/">Larvatus Prodeo</a> came on board and expected it to work for them too. But it simply hung without giving much in the way of error message. I pottered around with it at the time without much success.</p>
<p>Today it occurred to me that the problem is the way BLC works. BLC aims at being compatible with MySQL 3.x. Among other things, this means giving up subqueries and having piss-poor SELECT DISTINCT.</p>
<p>So BLC issues this beauty of a query:<br />
<code>SELECT comment_post_ID, post_title<br />
FROM (wp_comments LEFT JOIN wp_posts ON (comment_post_ID = ID))<br />
WHERE comment_approved = '1'<br />
AND wp_posts.post_status='publish'<br />
AND comment_type&lt;&gt;'pingback'<br />
AND comment_type&lt;&gt;'trackback'<br />
ORDER BY comment_date DESC;</code></p>
<p>This query pulls out the post ID and post_title for every approved, published comment in the database. On a site like Larvatus Prodeo, the results run to ~165k lines. BLC pulls these results into PHP as objects, one for each line; then it merges down the results to determine which posts have comments.</p>
<p>As you can imagine, this is memory intensive. Very memory intensive. And it&#8217;s a bit brutal on the CPU too, especially when garbage collection occurs. The upshot is that on Larvatus Prodeo, BLC exceeds the memory limits for PHP, and that for other sites, it adds about between 600 and 1200 milliseconds of processing time. Not cool.</p>
<p>Naturally, I&#8217;m running MySQL 5.x on my server, so SELECT DISTINCT works &#8216;as advertised&#8217;. So I&#8217;ve implemented a super high tech optimisation on BLC:</p>
<p><code>SELECT <strong>DISTINCT</strong> comment_post_ID, post_title<br />
FROM (wp_comments LEFT JOIN wp_posts ON (comment_post_ID = ID))<br />
WHERE comment_approved = '1'<br />
AND wp_posts.post_status='publish'<br />
AND comment_type&lt;&gt;'pingback'<br />
AND comment_type&lt;&gt;'trackback'<br />
ORDER BY comment_date DESC;</code></p>
<p>While this query is slower than the original, it basically returns only the list of posts with comments on them. On Larvatus Prodeo, this is a much more manageable ~2.5k lines of results. The reduction in PHP runtime completely overshadows the increase in query time; and besides, the smaller result sets don&#8217;t clog up the MySQL query cache.</p>
<p>So there you have it: a one-word way to dramatically improve the performance of Brian&#8217;s Latest Comments on MySQL 5.x-backed WordPress.</p>
<p><strong>Update:</strong> Two additional optimisations are worthy. First, add a LIMIT clause to your copy of BLC along the lines of:<br />
<code><br />
 $posts = $wpdb-&gt;get_results("SELECT DISTINCT<br />
                comment_post_ID, post_title<br />
                FROM ($wpdb-&gt;comments LEFT JOIN $wpdb-&gt;posts ON (comment_post_ID = ID))<br />
                WHERE comment_approved = '1'<br />
                AND $wpdb-&gt;posts.post_status='publish'<br />
                $ping<br />
                ORDER BY comment_date DESC<br />
                LIMIT $num_posts;");</code></p>
<p>Second, the SELECT DISTINCT hammers the tables much harder, so add indexes for the relevant fields:</p>
<p><code>CREATE INDEX post_status_index ON wp_posts(post_status);<br />
CREATE INDEX comment_date_index ON wp_comments(comment_date);<br />
CREATE INDEX comment_type_index ON wp_comments(comment_type);<br />
CREATE INDEX comment_date_approved_index ON wp_comments(comment_date_gmt);<br />
CREATE INDEX post_title_index ON wp_posts(post_title(50));</code></p>
<p><strong>Update 2:</strong> The query above doesn&#8217;t order the results according to the time of the latest comments; it winds up ordering by posting date. Not what my users want. Try this instead:</p>
<p><code>   $posts = $wpdb-&gt;get_results("SELECT comment_post_ID, post_title, max(comment_date) AS max_date<br />
                FROM ($wpdb-&gt;comments LEFT JOIN $wpdb-&gt;posts ON (comment_post_ID = ID))<br />
                WHERE comment_approved = '1'<br />
                AND $wpdb-&gt;posts.post_status='publish'<br />
                $ping<br />
                GROUP BY post_title<br />
                ORDER BY max_date DESC<br />
                LIMIT $num_posts;");</code></p>
<p><strong>Update 3:</strong> Nope. Performance is still atrocious. I&#8217;ll revisit this in a few weeks when I&#8217;ve settled in Darwin.</p>
]]></content:encoded>
			<wfw:commentRss>http://chester.id.au/2010/08/06/brians-latest-comments-doesnt-scale/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>More tweaking for Ozblogistan</title>
		<link>http://chester.id.au/2010/08/06/more-tweaking-for-ozblogistan/</link>
		<comments>http://chester.id.au/2010/08/06/more-tweaking-for-ozblogistan/#comments</comments>
		<pubDate>Fri, 06 Aug 2010 05:57:25 +0000</pubDate>
		<dc:creator>Jacques Chester</dc:creator>
				<category><![CDATA[Technical Notes]]></category>

		<guid isPermaLink="false">http://chester.id.au/?p=392</guid>
		<description><![CDATA[I did some minor optimisations on Ozblogistan last weekend. I have HTTP compression enabled on the webserver (gzip, to be precise). I found out through the excellent YSlow plugin that not everything was being compressed. HTML was compressed, but not style sheets or scripts. The nginx settings are now as follows: gzip on; gzip_buffers 128 [...]]]></description>
			<content:encoded><![CDATA[<p>I did some minor optimisations on Ozblogistan last weekend.</p>
<p>I have HTTP compression enabled on the webserver (gzip, to be precise). I found out through the excellent YSlow plugin that not everything was being compressed. HTML was compressed, but not style sheets or scripts.</p>
<p>The nginx settings are now as follows:</p>
<p><code>    gzip  on;<br />
    gzip_buffers 128 8k;<br />
    gzip_types text/plain application/xml text/xml application/xml+rss text/css application/x-javascript text/javascript application/xhtml+xml;<br />
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";</code></p>
<p>This provides a large buffer to prevent unexpected hangs. I&#8217;ve added mimetypes for javascript, RSS feeds and CSS files.</p>
<p>On the MySQL front, I received some advice from MySQL expert <a href="http://blog.dbadojo.com/">Paul Moen</a> of <a href="http://www.pythian.com/">Pythian</a>.</p>
<p>Paul&#8217;s main advice upon looking over the MySQL settings was to increase the key_buffer variable from 8Mb. It&#8217;s currently at 96Mb. This has sped up some queries. He also advised enabling and watching MySQL&#8217;s slow query log. This helped me spot queries where indexes might speed up things, so I added a few to relevant columns which also reduced the number of slow queries. Thanks Paul.</p>
<p>Another change was to notice that the advice for setting connection_max in MySQL is essentially Apache/mod_php-specific. It doesn&#8217;t make sense in a FastCGI context. In FastCGI you launch a fixed number of PHP instances. The number of connections from WordPress into MySQL is limited to the number of PHP instances; so there&#8217;s no requirement to set a higher connection_max setting. This is not an optimisation <em>per se</em>, but it tidies things up a bit.</p>
<p>I double checked my PHP opcode cacher XCache and found that it was not enabled. Annoyingly, aptitude will install but not activate this for you. To actually enable it, it&#8217;s necessary to edit the php.ini file and add a line:<br />
<code>extension=xcache.so</code><br />
Somewhere in the file.</p>
<p>Previously I have added favicons. Watching the error log, I saw requests for apple-touch-icon.png. Apple, in their infinite wisdom, have decided to add Yet Another Assumed File to the list of things webmasters need to know about. I&#8217;ve gone through and added icons for each of the Ozblogistan sites. It was, I must tell you, tedious and time-consuming. Though Apple currently scale the images to 57&#215;57, they will almost definitely upgrade this in future, so I&#8217;ve placed 128&#215;128 icons for now.</p>
<p>Finally, I adjusted the &#8216;swappiness&#8217; of the server. I configure PHP and MySQL to occupy less than the full RAM available; thus, I don&#8217;t want anything swapped out to disk. I&#8217;ve set swappiness to 0, which tells Linux to keep applications in memory at all times until it has no choice other than to swap them out.</p>
]]></content:encoded>
			<wfw:commentRss>http://chester.id.au/2010/08/06/more-tweaking-for-ozblogistan/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress import/export is still pants</title>
		<link>http://chester.id.au/2010/07/24/wordpress-importexport-is-still-pants/</link>
		<comments>http://chester.id.au/2010/07/24/wordpress-importexport-is-still-pants/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 05:36:53 +0000</pubDate>
		<dc:creator>Jacques Chester</dc:creator>
				<category><![CDATA[Geeky Musings]]></category>
		<category><![CDATA[Metablogging]]></category>

		<guid isPermaLink="false">http://chester.id.au/?p=389</guid>
		<description><![CDATA[It still chokes on &#8216;large&#8217; files due to causing massive blooms of memory consumption. The XML parser implementation used insists on loading the whole file at once. This is a recipe for PHP choking a modest VPS. A WXR splitter (there are several) is pretty much required. Why doesn&#8217;t WordPress perform this task itself? It&#8217;d [...]]]></description>
			<content:encoded><![CDATA[<p>It still chokes on &#8216;large&#8217; files due to causing massive blooms of memory consumption. The XML parser implementation used insists on loading the whole file at once. This is a recipe for PHP choking a modest VPS.</p>
<p>A WXR splitter (there are several) is pretty much <em>required</em>. Why doesn&#8217;t WordPress perform this task itself?</p>
<p>It&#8217;d also be nice if it did even very basic duplicate checking.</p>
]]></content:encoded>
			<wfw:commentRss>http://chester.id.au/2010/07/24/wordpress-importexport-is-still-pants/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Guilty pleasures</title>
		<link>http://chester.id.au/2010/07/20/guilt-pleasures/</link>
		<comments>http://chester.id.au/2010/07/20/guilt-pleasures/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 12:02:40 +0000</pubDate>
		<dc:creator>Jacques Chester</dc:creator>
				<category><![CDATA[Beautiful Women]]></category>
		<category><![CDATA[Films and TV]]></category>

		<guid isPermaLink="false">http://chester.id.au/?p=387</guid>
		<description><![CDATA[Australia&#8217;s Next Top Model is back. I recommend following each episode with bracing doses of Bland Canyon and Jo-Jo Blogs.]]></description>
			<content:encoded><![CDATA[<p><em>Australia&#8217;s Next Top Model</em> is back. I recommend following each episode with bracing doses of <a href="http://blandcanyon.blogspot.com/">Bland Canyon</a> and <a href="http://jo-joblogs.blogspot.com/">Jo-Jo Blogs</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://chester.id.au/2010/07/20/guilt-pleasures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Zealand has better IT policy than Australia</title>
		<link>http://chester.id.au/2010/07/15/new-zealand-has-better-it-policy-than-australia/</link>
		<comments>http://chester.id.au/2010/07/15/new-zealand-has-better-it-policy-than-australia/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 05:22:32 +0000</pubDate>
		<dc:creator>Jacques Chester</dc:creator>
				<category><![CDATA[Economics and public policy]]></category>
		<category><![CDATA[IT and Internet]]></category>

		<guid isPermaLink="false">http://chester.id.au/?p=385</guid>
		<description><![CDATA[Firstly, they don&#8217;t have Stephen Conroy. Secondly, they&#8217;re not going to introduce software patents. NZ: 2. Australia: Sux.]]></description>
			<content:encoded><![CDATA[<p>Firstly, they don&#8217;t have Stephen Conroy.</p>
<p>Secondly, they&#8217;re <a href="http://www.nzcs.org.nz/news/blog.php?/archives/97-.html">not going to introduce software patents</a>.</p>
<p>NZ: 2. Australia: Sux.</p>
]]></content:encoded>
			<wfw:commentRss>http://chester.id.au/2010/07/15/new-zealand-has-better-it-policy-than-australia/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sara Lee &#8220;Beef&#8221; Lasagne</title>
		<link>http://chester.id.au/2010/07/15/sara-lee-beef-lasagne/</link>
		<comments>http://chester.id.au/2010/07/15/sara-lee-beef-lasagne/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 04:00:32 +0000</pubDate>
		<dc:creator>Jacques Chester</dc:creator>
				<category><![CDATA[Food]]></category>

		<guid isPermaLink="false">http://chester.id.au/?p=381</guid>
		<description><![CDATA[I found one of these in the freezer outside and cooked it. The packaging says it&#8217;s made with &#8220;100% Australian beef&#8221;. By &#8216;beef&#8217; they mean that a cow managed to wander into the factory once. They had to herd it out past the lasagne department. &#8220;I have a great idea!&#8221;, says the marketing chief. There [...]]]></description>
			<content:encoded><![CDATA[<p>I found one of these in the freezer outside and cooked it. The packaging says it&#8217;s made with &#8220;100% Australian beef&#8221;.</p>
<p>By &#8216;beef&#8217; they mean that a cow managed to wander into the factory once. They had to herd it out past the lasagne department. &#8220;I have a great idea!&#8221;, says the marketing chief.</p>
<p>There are tofu cubes with more beef in them, I reckon.</p>
]]></content:encoded>
			<wfw:commentRss>http://chester.id.au/2010/07/15/sara-lee-beef-lasagne/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I&#8217;m moving back to Darwin.</title>
		<link>http://chester.id.au/2010/07/13/im-moving-back-to-darwin/</link>
		<comments>http://chester.id.au/2010/07/13/im-moving-back-to-darwin/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 05:03:49 +0000</pubDate>
		<dc:creator>Jacques Chester</dc:creator>
				<category><![CDATA[Diary]]></category>

		<guid isPermaLink="false">http://chester.id.au/?p=379</guid>
		<description><![CDATA[Since leaving The Frontier Group in late June I&#8217;ve been watching the job lines and shooting off resumes here and there. I&#8217;ve been to a few interviews, had a few offers, but now I&#8217;ve decided to take a job at CDU in Darwin. When I sent my resume to CDU, I didn&#8217;t hear back from [...]]]></description>
			<content:encoded><![CDATA[<p>Since leaving The Frontier Group in late June I&#8217;ve been watching the job lines and shooting off resumes here and there. I&#8217;ve been to a few interviews, had a few offers, but now I&#8217;ve decided to take a job at CDU in Darwin.</p>
<p>When I sent my resume to CDU, I didn&#8217;t hear back from them for a few weeks. I figured they&#8217;d quietly discarded my resume, which I was a bit sad about. Then, while I was on holiday in Darwin, they rang to ask if I could do a phone interview. Luckily I was in a position to interview in person, which I think helped my chances.</p>
<p>Last week CDU offered me the spot, with a good base rate and excellent (17%) superannuation. The super is one of the things I found most attractive. Also attractive were the location (I&#8217;m a Darwin boy) and the opportunity to become familiar with Oracle technologies, which continue to be in wide demand.</p>
<p>I&#8217;ve verbally accepted the offer today and I expect to receive the contract paperwork in the next few days. I&#8217;m looking forward to it.</p>
]]></content:encoded>
			<wfw:commentRss>http://chester.id.au/2010/07/13/im-moving-back-to-darwin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to run an opensource project.</title>
		<link>http://chester.id.au/2010/04/01/how-to-run-an-opensource-project/</link>
		<comments>http://chester.id.au/2010/04/01/how-to-run-an-opensource-project/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 11:28:53 +0000</pubDate>
		<dc:creator>Jacques Chester</dc:creator>
				<category><![CDATA[Geeky Musings]]></category>

		<guid isPermaLink="false">http://chester.id.au/?p=376</guid>
		<description><![CDATA[Step 1: Create a direct financial incentive to produce a buggy, security-hole-ridden, backwards but oh-so-shiny piece of poop. Step 2: ??? Step 3: Profit.]]></description>
			<content:encoded><![CDATA[<p>Step 1: Create <a href="http://vaultpress.com/">a direct financial incentive</a> to produce a buggy, security-hole-ridden, backwards but oh-so-shiny piece of poop.<br />
Step 2: ???<br />
Step 3: Profit.</p>
]]></content:encoded>
			<wfw:commentRss>http://chester.id.au/2010/04/01/how-to-run-an-opensource-project/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
