HipHop for PHP isn't technically a compiler itself. Rather it is a source code transformer. HipHop programmatically transforms your PHP source code into highly optimized C++ and then uses g++ to compile it. HipHop executes the source code in a semantically equivalent manner and sacrifices some rarely used features -- such as eval() -- in exchange for improved performance. HipHop includes a code transformer, a reimplementation of PHP's runtime system, and a rewrite of many common PHP Extensions to take advantage of these performance optimizations.The transformation process includes three main steps: 1. Static analysis where the system collects information on who declares what and dependencies 2. Type inference where it chooses the most specific type between C++ scalars, String, Array, classes, Object, and Variant 3. Code generation which for the most part is a direct correspondence from PHP statements and expressions to C++ statements and expressions. Overall HipHop allowed Facebook to keep the best aspects of PHP while taking advantage of the performance benefits of C++. In total, they have written over 300,000 lines of code and more than 5,000 unit tests. All of this is released on GitHub under the open source PHP license.
-
Facebook Releases HipHop JIT (9 messages)
- Posted by: Eugene Ciurana
- Posted on: February 03 2010 09:47 EST
Facebook announced the HipHop for PHP runtime environment. HipHop provides JIT capabilities to PHP that supercede the traditional PHP runtime and provide better page rendering performance with lower CPU usage. HipHop helps to provide massive PHP scalability and optimal interfacing with Java, Python, and C++ back-ends. Rather than using a complicated HTML particle caching system, or source-level code transformations, Haiping Zhao of Facebook describes how HipHop works:Threaded Messages (9)
- Re: Facebook Releases HipHop JIT by Nagraj Chakravarty on February 03 2010 14:35 EST
- Re: Facebook Releases HipHop JIT by Eugene Ciurana on February 03 2010 15:48 EST
- JIT what? by Jevgeni Kabanov on February 03 2010 16:59 EST
- P8 by Diego Visentin on February 03 2010 18:08 EST
- Re: Facebook Releases HipHop JIT by Bruce Fancher on February 04 2010 23:18 EST
- Re: Facebook Releases HipHop JIT by augustientje bloem on February 05 2010 14:31 EST
- Link is broken by Eren Aykin on February 08 2010 08:27 EST
- No eval? by Joao Del Valle on February 10 2010 07:27 EST
- Surprised by Arnold Sims on May 29 2010 14:57 EDT
-
Re: Facebook Releases HipHop JIT[ Go to top ]
- Posted by: Nagraj Chakravarty
- Posted on: February 03 2010 14:35 EST
- in response to Eugene Ciurana
Very nice work. But does it do all the operations (1. Static analysis, 2. Type inference 3. Code generation , 4. Compilation of C++ in binary ) at run time? Isn't a just-in-time compiler kick in at run time ? -
Re: Facebook Releases HipHop JIT[ Go to top ]
- Posted by: Eugene Ciurana
- Posted on: February 03 2010 15:48 EST
- in response to Nagraj Chakravarty
Very nice work. But does it do all the operations (1. Static analysis, 2. Type inference 3. Code generation , 4. Compilation of C++ in binary ) at run time?
Based on how PHP works, and how they extended it, this is effectively happening "at run-time". The operations are optimized upon page requests and the decision to run a PHP script through this process is automated. I think the most interesting part of this approach is that it entirely bypasses the "gold standard" of PHP performance engines, Zend. HipHop indicates that Facebook believes it's easier and more cost-effective to come up with this JIT setup than to try to tweak Zend into doing what they need. Cheers! E http://ciurana.eu
Isn't a just-in-time compiler kick in at run time ? -
JIT what?[ Go to top ]
- Posted by: Jevgeni Kabanov
- Posted on: February 03 2010 16:59 EST
- in response to Eugene Ciurana
Awesome news! Wonder if Quercus is faster than HipHop? @Eugene Was the "JIT" part mentioned anywhere or did you just add it yourself? JIT stands for Just-In-Time, which is an adjective, not a noun, so it doesn't make any sense in this context. Also I don't see it mentioned anywhere else and it's not what is commonly understood as a just-in-time compiler as they are definitely doing the compilation ahead-of-time. -
P8[ Go to top ]
- Posted by: Diego Visentin
- Posted on: February 03 2010 18:08 EST
- in response to Jevgeni Kabanov
Another solution for faster PHP code is P8, part of ProjectZero: http://www.projectzero.org/wiki/Development/PhpWebWhatPHP http://www.projectzero.org/php/ -
Re: Facebook Releases HipHop JIT[ Go to top ]
- Posted by: Bruce Fancher
- Posted on: February 04 2010 23:18 EST
- in response to Eugene Ciurana
I wonder how the performance compares with Quercus? -
Re: Facebook Releases HipHop JIT[ Go to top ]
- Posted by: augustientje bloem
- Posted on: February 05 2010 14:31 EST
- in response to Bruce Fancher
I wonder how the performance compares with Quercus?
Indeed, I'm very curious about that too. -
Link is broken[ Go to top ]
- Posted by: Eren Aykin
- Posted on: February 08 2010 08:27 EST
- in response to Eugene Ciurana
The github link provided above does not work ATM. This is the address of the discussion group: http://groups.google.com/group/hiphop-php-dev?pli=1 -
No eval?[ Go to top ]
- Posted by: Joao Del Valle
- Posted on: February 10 2010 07:27 EST
- in response to Eugene Ciurana
Good work! I'm wondering if without eval() we won't loose some nice dynamic aspects of PHP. I can think of a few frameworks that would not work on HipHopJIT. What about reflection and references like $this->$$varName ? -
Surprised[ Go to top ]
- Posted by: Arnold Sims
- Posted on: May 29 2010 14:57 EDT
- in response to Eugene Ciurana
I thought for sure that they would be using Zend, but it turns out not. This could have interesting implications for PHP performance. A lot of file sharing sites use a similar setup and will probably using this as well. When I was looking for a <!-- BODY,DIV,TABLE,THEAD,TBODY,TFOOT,TR,TH,TD,P { font-family:"Arial"; font-size:x-small } --> demonoid invitation code I came across many uses for this. Thanks.