<?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>The This Aint News Development Blog</title>
	<atom:link href="http://tan.per.ly/feed/" rel="self" type="application/rss+xml" />
	<link>http://tan.per.ly</link>
	<description>Just another per.ly php perl... weblog :</description>
	<lastBuildDate>Fri, 19 Aug 2011 02:27:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>It&#8217;s been a while</title>
		<link>http://tan.per.ly/2011/08/19/its-been-a-while/</link>
		<comments>http://tan.per.ly/2011/08/19/its-been-a-while/#comments</comments>
		<pubDate>Fri, 19 Aug 2011 02:27:36 +0000</pubDate>
		<dc:creator>tan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tan.per.ly/?p=46</guid>
		<description><![CDATA[It&#8217;s been a while since I&#8217;ve wrote anything on here, and there&#8217;s been things happening, both in my life (I&#8217;m now in Australia) and over at TAN. Since this is the This Aint News shameless linkspam blog development blog, I should probably write about that. So, what to write about? I guess I&#8217;ll start with [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a while since I&#8217;ve wrote anything on here, and there&#8217;s been things happening, both in my life (I&#8217;m now in Australia) and over at <a title="This Aint News" href="http://thisaintnews.com">TAN</a>. Since this is the <a title="TAN" href="http://thisaintnews.com">This Aint News</a> <del>shameless linkspam blog</del> development blog, I should probably write about that.</p>
<p>So, what to write about? I guess I&#8217;ll start with the CPAN <a href="http://search.cpan.org/~nobody/">modules</a> I&#8217;ve released from the <a title="This Aint News" href="http://thisaintnews.com">TAN</a> tree.</p>
<p>The first module I released was <a href="http://search.cpan.org/~nobody/KinoSearchX-Simple-0.10/lib/KinoSearchX/Simple.pm">KinoSearchX::Simple</a>, I think. I can&#8217;t be entirely sure, since it was quite a while ago! For those who don&#8217;t know, <a href="http://search.cpan.org/~creamyg/KinoSearch1-1.01/lib/KinoSearch1.pm">KinoSearch</a> is very similar to <a href="http://search.cpan.org/~tmtm/Plucene-1.25/lib/Plucene.pm">Plucene</a>, only it&#8217;s not an entirely abandoned project, and it&#8217;s very fast.</p>
<p>As the name implies, <a href="http://search.cpan.org/~nobody/KinoSearchX-Simple-0.10/lib/KinoSearchX/Simple.pm">KinoSearchX::Simple</a> is just a simple, <a href="http://search.cpan.org/~doy/Moose-2.0202/lib/Moose.pm">Moose</a> based, interface to <a href="http://search.cpan.org/~creamyg/KinoSearch1-1.01/lib/KinoSearch1.pm">KinoSearch1</a>, that hides most of the hard work under the bonnet. It&#8217;s nice and simple to use, and works pretty well. I know of two places it&#8217;s used, one is in a search service at an old job I used to work at, and the other is on <a title="This Aint News" href="http://thisaintnews.com">TAN</a> itself.</p>
<p>One day I intend to rewrite it, perhaps <a href="http://search.cpan.org/~doy/Moose-2.0202/lib/Moose.pm">Moose</a> free, for <a href="http://search.cpan.org/~creamyg/KinoSearch-0.313/lib/KinoSearch.pod">KinoSearch3</a>, which adds new features, and near realtime indexing. But that&#8217;s a task for another day.</p>
<p>Now I did have issues with this module and <a title="This Aint News" href="http://thisaintnews.com">TAN</a> the <a href="http://search.cpan.org/~bobtfish/Catalyst-Runtime-5.90001/lib/Catalyst.pm">Catalyst</a> application, in that when things got added to the index, because there was multiple copies of the index open in the different apache processes, sometimes they would be added repeatedly, or not at all. I solved that issue with the next module, which strangely is one of the newest I&#8217;ve released.</p>
<p><a href="http://search.cpan.org/~nobody/GearmanX-Simple-Worker-0.001/lib/GearmanX/Simple/Worker.pm">﻿GearmanX::Simple::Worker</a> &#8211; you&#8217;ll soon notice that there&#8217;s a pattern emerging here, with modules having the word &#8220;Simple&#8221; in them. Maybe that&#8217;s just me, but I like things to be easy ;)</p>
<p>So it wasn&#8217;t long ago when I wanted to create a <a href="http://twitter.com/#!/thisaintnews">TAN twitter</a> page, with the recent promotions spammed off to twitter automatically. Seemed like a good idea, but I&#8217;m not really a fan of things that talk to other websites running in process.</p>
<p>Such as the sitemap pinger I had, which was a little script that ran 24/7 and used inotify to watch for a new file to tell it to tell the various search engines that there was new content in the sitemaps. This solution, as it sounds, isnt perfect, but it did the job and I never gave it anymore thought.</p>
<p>At one <a href="http://northwestengland.pm.org/">NWE.pm</a> meeting though me, Rob and Matt were talking about jobservers, and that&#8217;s when I first learned about Gearman. So after a small discussion, and several beers, I was sold. The next week I decided I was going to kill 2 birds with one stone, and write the twitter spam script, and start using gearman.</p>
<p>Thus, <a href="http://search.cpan.org/~nobody/GearmanX-Simple-Worker-0.001/lib/GearmanX/Simple/Worker.pm">﻿GearmanX::Simple::Worker</a> was born, which is now used for several things. Spamming twitter with new content, pinging the search engines, and adding content to the search index, which solved the issue with duplicate and missing content from the index.</p>
<p>My favourite one has to be <a href="http://search.cpan.org/~nobody/Exception-Simple-0.004/lib/Exception/Simple.pm">Exception::Simple</a> though, which is really really simple. This came about because once again at a <a href="http://northwestengland.pm.org/">NWE.pm</a> meeting I heard about <a href="http://search.cpan.org/~doy/Try-Tiny-0.09/lib/Try/Tiny.pm">Try::Tiny</a>, which I instantly loved. Although using it and using die(&#8220;blah&#8221;) just didn&#8217;t seem very nice to me. I looked around CPAN, and could only find heavy weight exception classes, even <a href="http://search.cpan.org/~elisheva/Exception-Lite-0.999_004/lib/Exception/Lite.pod">Exception::Lite</a> seemed overly heavy for my needs. Then I stumbled upon <a href="http://search.cpan.org/~bobtfish/Catalyst-Runtime-5.90001/lib/Catalyst/Exception.pm">Catalyst::Exception</a>, which looked good and did exactly what I needed.</p>
<p>Though when I looked underneath it seemed to be a bit more complex than I needed. So then I made <a href="http://search.cpan.org/~nobody/Exception-Simple-0.004/lib/Exception/Simple.pm">Exception::Simpl</a>e which did everything I needed in under 70 lines of code. I released it and forgot about it, then one day out of the blue, I got an email and a patch, which made it more extensible to subclasses. Which made my day; it just shows, if you write it and release it, then someone out there might just use it, and even improve it, which is cool as!</p>
<p>Anyway, I&#8217;m bored of writing about modules now, especially since the other 3 are old, one collects an image from a remote website, the other validates its an image, and the other converts a url for a video into a html embed code. I&#8217;ll write something on these in a few years probably ;)</p>
<p>The reason I wrote this blog (other than the obvious link spam) was to show what I&#8217;d learned, and that was how to make a CPAN module. So I was gonna write a blog on using ﻿﻿<a href="http://search.cpan.org/~adamk/Module-Install-1.01/lib/Module/Install.pod">Module::Install</a>, but this turned out not to be it, and it&#8217;s now dinner time. So maybe I&#8217;ll do that one next.</p>
<p>Who knows? Not me, that&#8217;s for sure.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://tan.per.ly/2011/08/19/its-been-a-while/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl is making me mad</title>
		<link>http://tan.per.ly/2009/12/02/perl-is-making-me-mad/</link>
		<comments>http://tan.per.ly/2009/12/02/perl-is-making-me-mad/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 20:42:42 +0000</pubDate>
		<dc:creator>tan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tan.per.ly/?p=37</guid>
		<description><![CDATA[But its not perls fault&#8230;. its mine, I suppose. No scratch that, its PHP&#8217;s fault. Damn it too hell indeed! So let me fill you in on some back story. Once upon a time, about a year back, I was all unemployed and that, and wanted to do some kind of career change, from nothing [...]]]></description>
			<content:encoded><![CDATA[<p>But its not perls fault&#8230;.</p>
<p>its mine, I suppose. No scratch that, its PHP&#8217;s fault. Damn it too hell indeed! So let me fill you in on some back story.</p>
<p>Once upon a time, about a year back, I was all unemployed and that, and wanted to do some kind of career change, from nothing (previously call centre/builder/bar staff) to something that paid pretty well, so I figured web developers get a lot of money, and theres a lot of room for promotion etc. Now, already possesing all the programming skillz known to man, I figured this would be easy enough.</p>
<p>Anyway, to cut a long story short, not knowing much about this web dev lark, I settled on php, mostly because I thought it was <em>the </em>language to do this, after all perl was well and truley dead at this point [sic] (btw, I have no idea what this sic means, I just figured it makes me look clever!). Any way, I wrote some codez, was pretty damn easy tbh, I had shit up and running faster than something very fast.</p>
<p>A month down the line I had that all sorted and needed to put my new found skillz to good use, so I started making <a href="http://thisaintnews.com">This Aint News &#8211; Social News for pirates</a></p>
<p>Anyway, I soon found out that php has some seriously bad programming techniques, such as jibbing everything into the index.php and letting it do all the magic. I figured this was cool, since it ran lightning fast, but I soon figured out this was pretty unmaintainable, so a few rewrites later I had something nice(ish).</p>
<p>So this was about 9months into me being dole scum, and I finally got a job, mostly I think coz I put the effort into making <a href="http://thisaintnews.com">TAN</a> however this job was perl based, and me having never used perl, I was all like, wow, this perl thing sucks.</p>
<p>Fast forward again a whole year, catalyst is beggining to look real nice, and I mean real nice, but slow. My current code was getting pretty hacky, so I decided once again I&#8217;d rewrite it, this time using MVC and a catalyst inspired design, needless to say it was epic, probably the best peice of php anyone anywhere had ever written &#8211; ever! Only it had a few issues, being of a catalyst inspired design, it was objecty, very very objecty. And as we all know, php has no concept of long running web apps.  However, I continued, and got right near the end of the final rewrite, only to discover there was no way this code was gonna run fast, since it had to initialise all the objects on <em>each</em> page request.</p>
<p>At this point I figured fuck it, I&#8217;ll remake the bastard in catalyst, it wont take too long, the code is pretty similar, its aware of all the cat stlye concepts (stash, flash, c (called f) etc).</p>
<p>Now this blog is coming to an end, I can get to the point I was trying to make, now I have to convert all this perfect php code to perl code, and I don&#8217;t want to, it just feels like I&#8217;m doing the same work once again, and theres no joy in it.</p>
<p>So to put it simply, I&#8217;m blaming everyone else, especially php, and perl for not having phps syntax/functions/object system</p>
<p>SAFE (btw, written, but not read)</p>
<p>p.s. template toolkit sucks, when it compiles the templates, it should compile each template into a super compiled template, not just convert the templates into perl and include the sub-templates  at run time, but thats a blog for another time.</p>
]]></content:encoded>
			<wfw:commentRss>http://tan.per.ly/2009/12/02/perl-is-making-me-mad/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Another nail in PHPs coffin</title>
		<link>http://tan.per.ly/2009/10/30/another-nail-in-phps-coffin/</link>
		<comments>http://tan.per.ly/2009/10/30/another-nail-in-phps-coffin/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 14:11:14 +0000</pubDate>
		<dc:creator>tan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tan.per.ly/?p=11</guid>
		<description><![CDATA[So, I was digging through an xdebug trace log for This Aint News, trying to figure out why a page took 0.9 seconds to process, first thing I discovered was the 0.4 seconds of that was includes. So, I was gonna look into this, but then I got distracted by the 0.0016 seconds for a [...]]]></description>
			<content:encoded><![CDATA[<p>So, I was digging through an <a href="http://xdebug.org/">xdebug</a> trace log for <a href="http://thisaintnews.com">This Aint News</a>, trying to figure out why a page took 0.9 seconds to process, first thing I discovered was the 0.4 seconds of that was includes. So, I was gonna look into this, but then I got distracted by the 0.0016 seconds for a filemtime(). So I thought, I know, I&#8217;ll do some testing.</p>
<p>So, I made 3 very simple tests in 3 languages, perl php and python. These tests stat the file &#8220;foo&#8221; 1,000,000 times, and I timed it with time. This is on a bang upto date Arch Linux install, kernel 2.6.31-arch, amd64, JFS, perl v5.10.1, php v 5.3.0, python 2.6.4</p>
<p>test0.pl</p>
<p>[perl]<br />
my $t = 1000000;</p>
<p>for (my $i=0;$i&lt;$t;++$i){<br />
stat(&#8216;foo&#8217;);<br />
}<br />
[/perl]</p>
<p>test0.php</p>
<p>[php]<br />
&lt;?php<br />
$t = 1000000;</p>
<p>for ($i=0;$i&lt;$t;++$i){<br />
# note, im using stat here, to keep the test<br />
# as similar as possible, but the results are the<br />
# same with filemtime<br />
stat(&#8216;foo&#8217;);<br />
}<br />
[/php]</p>
<p>test0.py</p>
<p>[python]<br />
import os</p>
<p># note the use of xrange() rather than range()<br />
# range is python, xrange is pure c, and thus fast<br />
# if you use range, the test becomes void<br />
t = xrange(1000000)</p>
<p>for i in t:<br />
os.stat(&#8216;foo&#8217;)<br />
[/python]</p>
<p>along with a file called &#8220;foo&#8221;, which is nothing more than a text file with some foo inside it.</p>
<p>So, I ran these tests 5 times each, averaged the run time and made this table</p>
<div>
<table id="g1.l" style="height: 98px" border="1" cellspacing="0" cellpadding="3" width="623">
<tbody>
<tr>
<td width="33.33%"> </td>
<td width="33.33%">run time (real)</td>
</tr>
<tr>
<td width="33.33%">perl</td>
<td width="33.33%">1.4038</td>
</tr>
<tr>
<td width="33.33%">php</td>
<td width="33.33%">24.3848</td>
</tr>
<tr>
<td width="33.33%">python</td>
<td width="33.33%">3.982</td>
</tr>
</tbody>
</table>
</div>
<p>So, this is not what I was expecting, I assumed they&#8217;d all be about the same speed, since stat is a os system call. So, time to figure out why php is about 23x slower than perl at doing a system call&#8230;</p>
<p>So, new test cases, same as above, only these only do one stat.</p>
<p>test1.pl</p>
<p>[perl]<br />
stat(&#8216;foo&#8217;);<br />
[/perl]</p>
<p>test1.php</p>
<p>[php]<br />
&lt;?php<br />
stat(&#8216;foo&#8217;);<br />
[/php]</p>
<p>test1.py</p>
<p>[python]<br />
import os<br />
os.stat(&#8216;foo&#8217;)<br />
[/python]</p>
<p>So I break out the handy tool strace, i won&#8217;t post the full output here, since no one wants to read all that stuff!</p>
<p>strace perl test1.pl<br />
<code>read(3, "stat('foo');\n", 4096)         = 13<br />
read(3, "", 4096)                       = 0<br />
close(3)                                = 0<br />
stat("foo", {st_mode=S_IFREG|0644, st_size=7, ...}) = 0<br />
exit_group(0)<br />
</code></p>
<p>ok, as you can see from above, which is just the last bit of of the strace output, perl has opened the perl script, and then stats the file &#8220;foo&#8221;, then exits. Not bad, overall nice clean execution, no unnecessary hanging around.</p>
<p>strace python test1.py<br />
<code>lseek(3, 0, SEEK_CUR)                   = 0<br />
read(3, "import os\nos.stat('foo')\n", 4096) = 25<br />
lseek(3, 25, SEEK_SET)                  = 25<br />
read(3, "", 4096)                       = 0<br />
close(3)                                = 0<br />
munmap(0x7f98237c1000, 4096)            = 0<br />
stat("foo", {st_mode=S_IFREG|0644, st_size=7, ...}) = 0<br />
rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7f9822ffe7e0}, {0x7f982330ca90, [], SA_RESTORER, 0x7f9822ffe7e0}, 8) = 0<br />
exit_group(0)                           = ?<br />
</code></p>
<p>ok, about the same as above, although it uses a different method of reading the python script, but essentailly the same, it reads the script, stats &#8220;foo&#8221; and exits. Overall theres more stuff involved in starting python, and its a little slower, but its still doing the right thing and exiting nice and quick.</p>
<p>So, now for the interesting one:</p>
<p>strace php test1.php<br />
<code>read(3, "&lt;?php\nstat('foo');\n", 4096)  = 19<br />
lseek(3, 0, SEEK_SET)                   = 0<br />
mmap(NULL, 528384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc5c49dc000<br />
rt_sigaction(SIGPROF, {0x5d47c0, [PROF], SA_RESTORER|SA_RESTART, 0x7fc5ca3dcf90}, {SIG_DFL, [], 0}, 8) = 0<br />
rt_sigprocmask(SIG_UNBLOCK, [PROF], NULL, 8) = 0<br />
fstat(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0<br />
fstat(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0<br />
fstat(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0<br />
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc5c49db000<br />
lseek(0, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)<br />
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0<br />
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0<br />
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0<br />
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc5c49da000<br />
lseek(1, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)<br />
fstat(2, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0<br />
fstat(2, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0<br />
lseek(2, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)<br />
getcwd("/srv/http/tmp", 4096)           = 14<br />
lstat("/srv/http/tmp/ph", {st_mode=S_IFREG|0644, st_size=19, ...}) = 0<br />
lstat("/srv/http/tmp", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0<br />
lstat("/srv/http", {st_mode=S_IFDIR|0755, st_size=32, ...}) = 0<br />
lstat("/srv", {st_mode=S_IFDIR|0755, st_size=16, ...}) = 0<br />
stat("ph", {st_mode=S_IFREG|0644, st_size=19, ...}) = 0<br />
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff6c6206b0) = -1 ENOTTY (Inappropriate ioctl for device)<br />
fstat(3, {st_mode=S_IFREG|0644, st_size=19, ...}) = 0<br />
mmap(NULL, 51, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fc5c49d9000<br />
munmap(0x7fc5c49d9000, 19)              = 0<br />
close(3)                                = 0<br />
munmap(0x7fc5cb988000, 4096)            = 0<br />
getcwd("/srv/http/tmp", 4096)           = 14<br />
lstat("/srv/http/tmp/foo", {st_mode=S_IFREG|0644, st_size=7, ...}) = 0<br />
lstat("/srv/http/tmp", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0<br />
lstat("/srv/http", {st_mode=S_IFDIR|0755, st_size=32, ...}) = 0<br />
lstat("/srv", {st_mode=S_IFDIR|0755, st_size=16, ...}) = 0<br />
lstat("/srv/http/tmp/foo", {st_mode=S_IFREG|0644, st_size=7, ...}) = 0<br />
lstat("/srv/http/tmp", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0<br />
lstat("/srv/http", {st_mode=S_IFDIR|0755, st_size=32, ...}) = 0<br />
lstat("/srv", {st_mode=S_IFDIR|0755, st_size=16, ...}) = 0<br />
lstat("/srv/http", {st_mode=S_IFDIR|0755, st_size=32, ...}) = 0<br />
lstat("/srv", {st_mode=S_IFDIR|0755, st_size=16, ...}) = 0<br />
getcwd("/srv/http/tmp", 4096)           = 14<br />
lstat("/srv/http/tmp/foo", {st_mode=S_IFREG|0644, st_size=7, ...}) = 0<br />
lstat("/srv/http/tmp", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0<br />
lstat("/srv/http", {st_mode=S_IFDIR|0755, st_size=32, ...}) = 0<br />
lstat("/srv", {st_mode=S_IFDIR|0755, st_size=16, ...}) = 0<br />
lstat("/srv/http/tmp/foo", {st_mode=S_IFREG|0644, st_size=7, ...}) = 0<br />
lstat("/srv/http/tmp", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0<br />
lstat("/srv/http", {st_mode=S_IFDIR|0755, st_size=32, ...}) = 0<br />
lstat("/srv", {st_mode=S_IFDIR|0755, st_size=16, ...}) = 0<br />
lstat("/srv/http", {st_mode=S_IFDIR|0755, st_size=32, ...}) = 0<br />
lstat("/srv", {st_mode=S_IFDIR|0755, st_size=16, ...}) = 0<br />
stat("foo", {st_mode=S_IFREG|0644, st_size=7, ...}) = 0<br />
munmap(0x7fc5c49dc000, 528384)          = 0<br />
close(2)                                = 0<br />
close(1)                                = 0<br />
munmap(0x7fc5c49da000, 4096)            = 0<br />
close(0)                                = 0<br />
munmap(0x7fc5c49db000, 4096)            = 0<br />
open("/dev/urandom", O_RDONLY)          = 0<br />
read(0, ":}\245\224D\332\372\257", 8)   = 8<br />
close(0)                                = 0<br />
open("/dev/urandom", O_RDONLY)          = 0<br />
read(0, "\4l\225d\3102\31)", 8)         = 8<br />
close(0)                                = 0<br />
open("/dev/urandom", O_RDONLY)          = 0<br />
read(0, "D\313N\344\363\271\25\37", 8)  = 8<br />
close(0)                                = 0<br />
setitimer(ITIMER_PROF, {it_interval={0, 0}, it_value={0, 0}}, NULL) = 0<br />
munmap(0x7fc5c4a5d000, 67108864)        = 0<br />
munmap(0x7fc5c8a5d000, 2273896)         = 0<br />
munmap(0x7fc5c8c89000, 2201824)         = 0<br />
munmap(0x7fc5c8ea3000, 2128608)         = 0<br />
munmap(0x7fc5c90ab000, 2107928)         = 0<br />
munmap(0x7fc5c9ef3000, 2157480)         = 0<br />
munmap(0x7fc5c9cae000, 2379592)         = 0<br />
munmap(0x7fc5c9a5f000, 2419920)         = 0<br />
munmap(0x7fc5c96d1000, 3726872)         = 0<br />
munmap(0x7fc5ca102000, 323584)          = 0<br />
exit_group(0)                           = ?<br />
</code></p>
<p>ok, same deal as before, the trace starts when the php script is read. First thoughts, wtf? perl/python do this in 3/10 lines respectively, but php, damn I can&#8217;t even count that many lines!!!</p>
<p>Right, so ignoring the massive amount of mess that happens once the script begins execution, and lets focus on the all important &#8220;stat(&#8220;foo&#8221;, {st_mode=S_IFREG|0644, st_size=7, &#8230;}) = 0&#8243; that we&#8217;re looking for, if you look closely you&#8217;ll see its in there some where, right under a load of very suspicious looking lstat system calls!</p>
<p><code>getcwd("/srv/http/tmp", 4096)           = 14<br />
lstat("/srv/http/tmp/ph", {st_mode=S_IFREG|0644, st_size=19, ...}) = 0<br />
lstat("/srv/http/tmp", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0<br />
lstat("/srv/http", {st_mode=S_IFDIR|0755, st_size=32, ...}) = 0<br />
lstat("/srv", {st_mode=S_IFDIR|0755, st_size=16, ...}) = 0<br />
stat("ph", {st_mode=S_IFREG|0644, st_size=19, ...}) = 0<br />
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff6c6206b0) = -1 ENOTTY (Inappropriate ioctl for device)<br />
fstat(3, {st_mode=S_IFREG|0644, st_size=19, ...}) = 0<br />
mmap(NULL, 51, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fc5c49d9000<br />
munmap(0x7fc5c49d9000, 19)              = 0<br />
close(3)                                = 0<br />
munmap(0x7fc5cb988000, 4096)            = 0<br />
getcwd("/srv/http/tmp", 4096)           = 14<br />
lstat("/srv/http/tmp/foo", {st_mode=S_IFREG|0644, st_size=7, ...}) = 0<br />
lstat("/srv/http/tmp", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0<br />
lstat("/srv/http", {st_mode=S_IFDIR|0755, st_size=32, ...}) = 0<br />
lstat("/srv", {st_mode=S_IFDIR|0755, st_size=16, ...}) = 0<br />
lstat("/srv/http/tmp/foo", {st_mode=S_IFREG|0644, st_size=7, ...}) = 0<br />
lstat("/srv/http/tmp", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0<br />
lstat("/srv/http", {st_mode=S_IFDIR|0755, st_size=32, ...}) = 0<br />
lstat("/srv", {st_mode=S_IFDIR|0755, st_size=16, ...}) = 0<br />
lstat("/srv/http", {st_mode=S_IFDIR|0755, st_size=32, ...}) = 0<br />
lstat("/srv", {st_mode=S_IFDIR|0755, st_size=16, ...}) = 0<br />
getcwd("/srv/http/tmp", 4096)           = 14<br />
lstat("/srv/http/tmp/foo", {st_mode=S_IFREG|0644, st_size=7, ...}) = 0<br />
lstat("/srv/http/tmp", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0<br />
lstat("/srv/http", {st_mode=S_IFDIR|0755, st_size=32, ...}) = 0<br />
lstat("/srv", {st_mode=S_IFDIR|0755, st_size=16, ...}) = 0<br />
lstat("/srv/http/tmp/foo", {st_mode=S_IFREG|0644, st_size=7, ...}) = 0<br />
lstat("/srv/http/tmp", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0<br />
lstat("/srv/http", {st_mode=S_IFDIR|0755, st_size=32, ...}) = 0<br />
lstat("/srv", {st_mode=S_IFDIR|0755, st_size=16, ...}) = 0<br />
lstat("/srv/http", {st_mode=S_IFDIR|0755, st_size=32, ...}) = 0<br />
lstat("/srv", {st_mode=S_IFDIR|0755, st_size=16, ...}) = 0<br />
stat("foo", {st_mode=S_IFREG|0644, st_size=7, ...}) = 0<br />
</code></p>
<p>So, this explains this then, when you ask php to stat a file, it doesn&#8217;t just stat the file that you asked it to stat, it goes all out and stats a whole load of other shite as well. This is ontop of the plethora of system calls just to get this far.</p>
<p>Too be honest, I&#8217;m seriously considering switching over to catalyst, the only problem I have is time, fortunatly, php and perl are very simialr in syntax, and my code is proper, not shitty n00b scripts, so it will convert to catalyst very quick.</p>
<p>Its a shame though, since I had big hopes for php, but after seeing how something as simple as a stat system call is messed up so bad that it becomes 23x slower than perl.</p>
<p>WTF???</p>
<p>note I also ran these tests on 3 different gentoo machines, as well as another Arch machine, and the results are all about the same, although they&#8217;re not on here because I don&#8217;t care enough, and it turns out I have a shite load of work ahead of me now, great :|</p>
]]></content:encoded>
			<wfw:commentRss>http://tan.per.ly/2009/10/30/another-nail-in-phps-coffin/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>This Aint News</title>
		<link>http://tan.per.ly/2009/10/29/this-aint-news/</link>
		<comments>http://tan.per.ly/2009/10/29/this-aint-news/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 13:56:01 +0000</pubDate>
		<dc:creator>tan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tan.per.ly/?p=3</guid>
		<description><![CDATA[Just some words about stuff.]]></description>
			<content:encoded><![CDATA[<p>So, at some point in the future I&#8217;m gonna write about <a href="http://thisaintnews.com">TAN</a> here, mostly about things I figure out whilst developing it.</p>
<p>Some future posts will be about phps really crap <a href="http://blog.milkfarmsoft.com/2006/06/fastcgi-in-php-the-way-it-could-be/">implimentation</a> of fastcgi/mod_php, and how this is <a href="http://blog.milkfarmsoft.com/2007/06/application-server-in-php-well…-yes/">changing</a>.</p>
<p>They&#8217;ll also be something about compiling pure php  templates to reduce page generation time. For example, a page on TAN includes 120 templates overall, this alone takes 0.4 seconds, which is about half of the total page load time!!!</p>
<p>The above blog will also lead onto xdebug, and why its <strong><em>*really*</em></strong> important that you don&#8217;t try to tune your app unless you <strong><em>*know exactly* </em></strong>why its going slow.</p>
<p>Then I&#8217;ll probably write some rubbish about php being better suited to simple web development, but lacking some crucial benefits of perl, and why this situation is changing.</p>
<p>That being said, I&#8217;m now going to slope away and probably never write anything else :p</p>
]]></content:encoded>
			<wfw:commentRss>http://tan.per.ly/2009/10/29/this-aint-news/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

