ข้อมูลเพิ่มเติมครับ
http://www.phpclasses.org/blog/post/117-PHP-compiler-performance.html
HipHop for PHP
HipHop is a PHP compiler project led by Haiping Zhou. Haiping was born in China but nowadays he works for Facebook as a Senior Software Engineer in their United States office.
HipHop transforms PHP source code into C++ code. Then the resulting C++ code can be compiled into native binary executable code with a C++ compiler, like for instance GCC.
HipHop was developed to make more efficient use of the Facebook servers. Currently, over 90% of Facebook Web traffic is handled by PHP code compiled by the HipHop compiler.
HipHop compiles the code of a set of PHP scripts into an executable program that works as a multi-threaded Web server. This way, the compiled PHP code not only runs faster but also makes more efficient use of server machine memory.
A multi-threaded Web server uses less memory because it uses a single memory pool for all simultaneous requests. This is different from using multi-process Web servers, like when you use Apache in pre-fork mode. This is the mode that most Apache based PHP sites use. In this mode, each request is handled by a separate OS process. Each process has its own memory pool.
The main problem of using multi-process Web servers is that when a process uses a large chunk of memory, that memory is not returned to the OS until the process exits. Even if subsequent requests handled by the same process do not need so much memory, the unused memory space cannot be reused by other processes that may be handling other simultaneous requests.
Apache can be forced to kill pre-forked processes once in a while in order to perform memory recycling, but there is always a waste of memory until the process exit happens.
The memory usage details are very important for sites that require more than one server machine. The memory used by the Web server processes determines how many simultaneous requests each Web server machine can handle.
For instance, if you have a Web server with 1GB of RAM and each PHP request takes 10MB of RAM, in theory it can handle less than 100 of simultaneous requests. If all programs running in the same machine use more than the physically available RAM, the OS has to use virtual memory and the machine starts slowing down, as it has to swap physical memory blocks with virtual memory segments in disk.
This is why a server that takes an excessive amount of simultaneous requests can be halted, causing what is known as a DOS: Denial Of Service. With Apache, you can use the configuration directive MaxClients to limit the number of simultaneous requests. That will prevent the machine to halt, but the Web server starts queuing incoming requests. This means that the requests may be handled with a great delay or even be ignored.
This is a matter that was previously discussed in a past article about the use of multi-threaded Web servers for handling high traffic. Notice that in that article it is recommended the use of multi-threaded Web servers only for serving static files like images, CSS and Javascript.
The new aspect of HipHop PHP compiler is that Facebook developers have made an effort to convert PHP extensions in such way that they are thread-safe. This means that they can run without crashing multi-threaded Web server programs, which is what the HipHop compiler generates.