KBD

Keith Devens .com

Saturday, March 20, 2010 Flag waving
Simplicity takes effort-- genius, even. – Paul Graham
← 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)
:

March 2010
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
28293031 



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

Recent comments XML

I hate ASP.NET

I hate ASP... I was doing wonders​with PHP, then suddenly one of my​clients...

Johnies: Mar 17, 6:14am

Quantum physics and free will

I knew you were going to say that....

Tom Massey: Mar 15, 9:26pm

Generated in about 0.207s.

(Used 8 db queries)