HipHop Virtual Machine(HHVM) for PHP
Rise of HHVM
In 2008, facebook engineers began working on HPHP. It’s first release aimed as PHP to C++ compiler known as HPHPc. PHP Code was written and transformed into c++, compiled into a binary and finally executed as executable. This is an opposite to optcodes and interpreted. As an adjunct to HPHPc, Facebook engineers also created a ‘developer mode’ known as HPHPi and a debugger HPHPd. This allowed the usual process of running PHP code with addition of Debugging. Both HPHPi and HPHPc played role in development mode and production mode respectively.
HPHPc allowed facbook running faster with less resources. The curve for further improvements had flattened leading to depreciation of this HPHP. To solve this they decide to create a new PHP virtual machine and they start development on early 2010. HHVM is built on top of HPHPc using same runtime and extension functionalities. Also it is similar to other virtual machines for languages like C#CLR and Java/JVM.
Power of HHVM
HHVM is intended to achieve both parity with the Zend Engine features and best possible performances. Facebook claims a 3x to 10x speed boost and 1/2 memory footprint by switching from PHP+APC to HHVM. Of course this is really application dependent (10x being for the FB code base).
By the end of last year, HHVM was already able to pass 98.5% of the unit tests for 20+ of the most popular PHP frameworks.
In a few months from now, we can expect more documentation and tooling from Facebook. You could even help by contributing to the project on github, there is also a bounty program in place.
As of today the HHVM executes PHP code faster than PHP while consuming less memory. That will be a significant advantage in favor of HHVM when the parity is eventually achieved.
HHVM can be run as a standalone webserver (i.e. without the Apache webserver and the “modphp” extension). HHVM can also be used together with a FastCGI-based webserver, and work is in progress to make HHVM work smoothly with Apache.
Installation
HHVM 2.4.0 is released.This release has many exciting points. First of all, 4 more large frameworks now pass 100% of their unit tests (using phpunit 3.9) – Laravel, Mockery, PHPUnit and CodeIgniter.
Use prebuilt package or compile from source.
Executing Scripts
You can run standalone programs just by passing them to hhvm.
hhvm my_script.php
To run HHVM as standalone web server on port 80 in the current directory:
sudo hhvm -m server
For advance configuration make a config.hdf and add to the start of server.
sudo hhvm -m server -c config.hdf
- Late Static Binding in PHP 5.3 - July 14, 2014
- Introduction to Web Notifications API - May 10, 2014
- Manage Dependency with Composer - April 21, 2014