
Facebook continues to work to improve the performance of the PHP code. In 2010, they released the HipHop compiler (HPHPc), which translated PHP to C ++, sacrificing some rarely used PHP functions like
eval()
, but increasing performance.
With an active audience of 1.1 billion people, Facebook is extremely interested in increasing the performance of web applications. Since many programmers are familiar with PHP, the company decided not to abandon this “slow” language, but try to optimize it as much as possible. By the way, it also does “Vkontakte” with the recently introduced
kPHP technology.
However, the previous approach to translating PHP code to C ++ had to be left. Instead, a virtual machine, environment, and JIT compiler for PHP are released, called
HipHop VM for PHP or simply HHVM. Here we are talking about increasing productivity by five to nine times.
In May, Facebook servers almost completely switched from HPHPc to HHVM. The
source code of the virtual machine and ready-made
builds for Ubuntu 12.04, Debian 7 (wheezy) and Centos 6.4 are available on Github. Soon they promise to add a package for FreeBSD 9.
')
According
to the representative of Facebook, who recently spoke at the O'Reilly Open Source Conference (OSCON), for a standard website, for example, on Wordpress hosting, the productivity increase will be small: only five times. Another thing, if we are talking about a large code base of PHP, it is for this optimized virtual machine HHVM, so that there can be a performance increase of nine times.
“If you take some PHP code and run it on HipHop, then the CPU will not be a limiting performance factor,” said Joel Pobar, development manager for Facebook. “Rather, you will see that the system spends more time querying the database or communicating with memcache.”
HHVM works on the JVM (Java Virtual Machine) pattern: the JIT compiler translates the source code into machine code when it is needed, and allows for various factors to be taken into account when generating machine code. For example, if there is a call to a MySQL database, then the JIT compiler will look at which data type is being called and generate the corresponding code on the fly.