Promatics Blog

Should developers be excited about Facebook’s HHVM yet?

We have all heard about HHVM but what is HHVM? It is the Hip Hop Virtual Machine!

HHVM is an open-source virtual machine that has been designed especially for executing programs written in Hack and PHP. It uses a just-in-time (JIT) compilation approach to achieve high quality performance and also gives development flexibility that PHP provides.

HHVM runs most of the existing PHP. The popularity of HHVM among the developers and hosts is increasing with the adoption of HHVM. Being open source there is a large community that maintains HHVM. The HHVM team, along with community members, has made it a high priority goal to run all existing PHP code existing out there. HHVM 3.8.0 is the latest version that is currently available.

HHVM features comprise of the following:

1. The Hack Language: Hack is a language for HHVM that interoperates seamlessly with PHP. HHVM supports both Hack and PHP; the code can be run on HHVM in either language or even a mixture of both.

2. JIT Compilation: Rather than directly interpret or compile PHP code directly to C++, HHVM compiles Hack and PHP into an intermediate bytecode. This bytecode is then translated into x64 machine code dynamically at runtime by a just-in-time (JIT) compiler. This compilation process allows for all sorts of optimizations that cannot be made in a statically compiled binary, thus enabling higher performance of Hack and PHP programs.

3. HNI: HHVM provides HNI (HHVM-Native Interface) when PHP just isn’t enough and you need to duck into C++, perhaps to call a library function.

4. FastCGI support: FastCGI is a protocol for communication between an application server (e.g. running your PHP code) and a webserver. With support for FastCGI, you can run HHVM behind any popular web server (Apache, Nginx, Lighttpd, etc). The webserver takes charge of handling all the intricate details of the HTTP protocol. HHVM is in charge of running PHP code at high speeds.

5. Increasing PHP5 Parity: Open Source Tests have given 92.91%, and there are around 27 Frameworks at 100%.

6. hphpd debugger: HHVM has a debugger called hphpd that can be used to debug a running program or can be used as a standalone line-by-line scratch pad for simple testing. It is easy to invoke hphpd, just by typing the following at the command line: hhvm -m debug [filename], filename is not needed if you want to run the debugger in a “standalone” format for quick testing.

The need to speed up: There are certain Benchmarks that have been published by Facebook that have definitely shown performance improvements for HHVM over both its previous versions and the stock PHP engine. But many PHP packages fail to take advantage of the functionality exposed by HHVM.

HHVM uses its JIT compiler to speed up execution of PHP code. The increase varies depending on the application, but the latest set of benchmarks released by Facebook puts HHVM at between two and four times faster than PHP 5, and from 1.1 to 1.5 times faster than PHP 7. Facebook noted, that none of the frameworks such as WordPress, Drupal etc, take advantage of the asynchronous I/O architecture available in HHVM. Greater accelerations are possible, but mainly with apps using asynchronous I/O rather than any changes in the PHP engine itself.

Hitting multiple Walls: In order to support its statement, Facebook performed its own experimental optimization of WordPress to use asynchronous database queries. Facebook found that this change can demonstrate performance gains in both Requests per second and response time. But detailed performance numbers were promised at a later date.

Another possible stumbling block to the switching of PHP for HHVM: Many PHP packages, as made available through Composer, don’t pass automated testing when run under HHVM.

The HHVM Support in PHP Projects site tracks Composer packages, many common options test successfully under HHVM, some work only in part and others don’t work at all. This makes HHVM useful for running the most commonly used frameworks and apps such as the WordPress.

Conclusion:
Over time, HHVM might achieve success for being a source of ideas for how future iterations of the stock PHP engine could be implemented. As long as majority of PHP applications aren’t modernized, the stock engine will be the best choice.

Promatics since its inception has been committed to deliver services that surpass excellence and tailored to cater the needs of an ever-evolving digital landscape. Promatics designs, develops and delivers web and mobile applications that drive today’s businesses, ameliorate and enhance business capability, reduce customer acquisition lead times, accelerate top line growth, create better brand and ultimately beat competition. Supported by excogitative research and development, Promatics uses its strengths in technology, software, mobile as well as customer service to create new revenue-generating opportunities for its customers and at the same time reducing the overheads, while enabling them to quickly deploy and better manage and direct their businesses.

Leave a Comment

You've decided to leave a comment. That's fantastic! Please keep in mind that comments are moderated. So, please do not abuse, use a spammy keyword or it will be deleted. Let's have a meaningful conversation instead. Thanks for dropping by!

Comment*

Enter same string as shown below:

Name*

Email*

Website

Search

Search

About Promatics

Promatics is an ISO 9001:2008 certified offshore web and mobile application development company with a strong team of 100+ highly skilled IT experts delighting SMEs across USA, Europe and APAC. Our services and solutions help clients to achieve tangible business value and remain competitive in today’s evolving marketplaces.