KBD

Keith Devens .com

Thursday, May 17, 2012 Flag waving
Would that which we have achieved have been possible if Providence had not helped us? – Adolf Hitler (in a speech at Regensburg on June 6th, 1937)
← ongoing · What the Spooks KnowCox & Forkum on the biggest story of 2005 →

Daily link icon Wednesday, December 21, 2005

PHP to Java compilation is faster than vanilla PHP? Duh.

This seems very misleading to me:

The other item that caught my eye was Cameron Purdy noting that Caucho claims to have a module that compiles PHP to bytecodes and runs it on the JVM four times faster than mod_php (first benchmark, but on a real app not synthetic). It’s GPL’ed. This is more than a little surprising.

Not really. It's not a direct comparison. First, PHP scripts are typically compiled to bytecode on each page execution. In addition, the Java app server they're running this on surely has a cache involved so that the compiled classes are kept in memory and aren't loaded on each page hit.

So, it's actually much closer to PHP when you're using one of PHP's bytecode caches, such as PHP Accelerator, which, what do you know, claims a 5-10 times speedup over normal PHP. Someone else even asks whether they were comparing it to PHP with a bytecode cache, but no response from Caucho.

However, Scott Ferguson (from Caucho) correctly points out that we should expect Java to be faster at certain things compared to PHP simply because of the semantics of the respective languages. Of course that's true. Plus, Java's obviously had way more effort and money thrown at its optimization than PHP has, and it even JIT's down to native code. So all of this makes it even more surprising that Java is only four times faster than Apache/mod_php if in fact they were comparing it to vanilla PHP with no bytecode cache.

Plus, as this is a comparison of server stacks and not merely language implementations, it's important to point out that Apache certainly isn't known for its speed. PHP would likely have performed much better running on lighttpd with FastCGI, as it's almost certain Caucho wasn't merely comparing code speed but requests-per-second. See these posts at TextDrive's weblog for more on lighttpd.

← ongoing · What the Spooks KnowCox & Forkum on the biggest story of 2005 →

Comments XML gif

Harry Fuecks (http://www.phppatterns.com) wrote:

The guys building php.NET (http://www.php-compiler.net/) also claim better performance: http://www.php-compiler.net/Benchmarks.htm

∴ Harry Fuecks | 21-Dec-2005 7:06am est | http://www.phppatterns.com | #8889

Keith (http://keithdevens.com/) wrote:

Unsurprising as well. What I have been surprised about in both these cases is that they're not much faster. That benchmarks page lists 1.7 to 2 times better running against a Zend Optimizer enabled install of PHP. And as those links from TextDrive show, you can significantly improve the performance of a PHP application just by running it on lighttpd.

Keith | 21-Dec-2005 4:36pm est | http://keithdevens.com/ | #8895

Feel free to post a comment below. Please see my comment policy.

Formatting Rules (No HTML):

  • **bold**, *italic*, _underlined_, --strikeout--
  • "text"="url" creates a link, and URLs are auto-highlighted
  • Blockquote: Like e-mail, begin paragraph with > (greater-than sign)
  • Lists: begin paragraph with *,-, or + (unordered), or # (ordered)
  • Code block: ?!code:language=perl|php|sql|javascript|etc.{\n}...{\n}?!/code

:
(will be your IP address if blank)
: (optional)
(Will not be shown on site)

: (optional)
:

May 2012
SunMonTueWedThuFriSat
 12345
6789101112
13141516171819
20212223242526
2728293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 4 posts

Recent comments XML

new⇒Acknowledging the Arrival of Peak Government

In many ways, Peak Oil is​responsible for this new​uselessness of the big g...

Revence: May 16, 6:35am

new⇒Tab EXSPLOSION

Right now, I, too, have too many​tabs open. A rough count says​25.
Right. ...

Revence: May 16, 6:21am

George W. Bush: ‘I’m for Mitt Romney’ - ABC News

A marked difference (departure,​even) from the KBD of eight--yea,​even four...

Revence: May 15, 1:55pm

WebOb — WSGI request and response objects

Google App Engine forces one to​learn these....

Revence: May 15, 1:52pm

Generated in about 0.219s.

(Used 8 db queries)