Tag: c++’
Scalability: Facebook Releases HipHop – An Open Source PHP to C++ Transformer
- by Asher Bond
Facebook is written mostly in PHP, which generally scales well for most sites. Large scale web sites can greatly reduce memory resource utilization as well as CPU resource utilization by eliminating unused and inefficient code instructions.
Although PHP is considered to be a scripting language, PHP’s parser does in fact compile code before it is processed by the Zend Engine. Opcode caching allows compiled PHP code to be shared and recycled in memory, rather than compiling the PHP source on the fly. Opcode caching is already available in Zend Server’s community edition and will be available when PHP6 is released.
HipHop takes a much more aggressive approach to performance optimization by translating the source code into C++ which can be compiled into more machine specific instructions. Not only does HipHop compile the source code into a more system friendly language, it also rewrites your code to be more efficient. Through static binding, scripty system calls and functions such as eval() are eliminated and loosely defined types are tightened up to meet specific runtime requirements. Here is an illustration of how HipHop optimizes PHP:
According to Facebook’s Senior Engineer Haiping Zhao, HipHop reduced Facebook’s CPU overhead by 50%!
HipHop will be released tonight under the open PHP license.