KBD

Keith Devens .com

Thursday, August 28, 2008 Flag waving
Never ascribe to malice, that which can be explained by incompetence. – Napoleon Bonaparte
← 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)
:

August 2008
SunMonTueWedThuFriSat
 12
3456789
10111213141516
17181920212223
24252627282930
31 



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

Recent comments XML

new⇒Girls, please don't get breast implants

http://war-11.ucufyod.net​http://jewelry-26.wohiles.net​http://games-52.ruz...

Randolph: Aug 28, 5:16am

Generated in about 0.379s.

(Used 8 db queries)

mobile phone