Facebook releases a PHP just-in-time compiler

Facebook finds a new way to render PHP even more quickly

In its continuing endeavor to serve its 800 million users as quickly as possible, Facebook is once again revamping the way it handles its PHP-based Web pages.

Friday, Facebook posted on GitHub its HipHop Virtual Machine (HHVM), which the company's engineers call a just-in-time PHP compiler. According to Facebook, this PHP execution engine is 60 percent faster than its current PHP interpreter and uses 90 percent less memory.

Facebook is currently using HHVM in its test environments as a replacement for its home-built PHP interpreter, and plans to eventually use it to run the PHP code for its website.

Facebook made its quest for faster PHP code public in 2010, when it released what it called a PHP source code transformer, called HipHop, which it had already been using in production.

PHP was originally designed as a Web scripting language, one used to add dynamic content to Web pages. PHP is a vital part of Facebook, in that it, along with JavaScript, is used to help assemble each user's unique home page. As with code rendered by most scripting languages, however, PHP applications do not run as fast as programs written in full-fledged programming languages such as C++, which are compiled into machine-readable byte code ahead of time.

Facebook's HipHop transforms PHP extensions into highly optimized C++ code, which means they run faster when executed. PHP developers at Facebook can write their extensions in PHP, and have HipHop transform it into C++ code, which then can be compiled into speedy binary objects.

The company migrated all its own servers over to HipHop in 2010, claiming that it had cut CPU usage in half. The company released the source code of HipHop so others could use it as well.

At the time, Facebook also developed a PHP interpreter, called HPHPi, which allows PHP developers to run their PHP code without compiling it. Code run on HPHPi is slower than code compiled and run on HipHop, but it provides developers with an easier way to debug their code.

With HHVM, Facebook engineers have combined the speed of a compiled language with the flexibility of a scripted language. "A dynamic translator can observe data types as the program executes, and generate type-specialized machine code," wrote Facebook software engineer Jason Evans, in a blog post announcing the release of HHVM.

HHVM also solves an internal problem for Facebook. HPHPi and HipHop "don't have identical language semantics," wrote Evans in an email interview. This means that code that runs perfectly well in an HPHPi test environment might not run on HipHop.

While Facebook designed HHVM primarily for its own use, such PHP acceleration technologies could be useful for other organizations using PHP as well, said IDC software analyst Al Hilwa. "Really complex PHP code can benefit from this type of optimization," he said. "PHP is the dominant server-side language and there are surprisingly large applications written in PHP."

Work still needs to be done on HHVM, according to Evans. The interpreter still needs to be tuned for production use. The translation cache needs to be refined, and its memory use needs to be reduced.

"We hope that the PHP community will find [HHVM] useful as it matures and engage with us to broaden its usefulness through technical discussions, bug reports, and code contributions," Evans wrote.

Joab Jackson covers enterprise software and general technology breaking news for The IDG News Service. Follow Joab on Twitter at @Joab_Jackson. Joab's e-mail address is Joab_Jackson@idg.com

Join the newsletter!

Or

Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.

Tags Facebooksoftwareapplication developmentWeb services developmentDevelopment toolsLanguages and standards

Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Joab Jackson

IDG News Service
Show Comments

Father’s Day Gift Guide

Brand Post

Bitdefender 2019

Bitdefender’s best-in-class security solutions have been awarded Product of the Year. Get cybersecurity that 500 MILLION users already have and trust!

Most Popular Reviews

Latest Articles

Resources

PCW Evaluation Team

Luke Hill

MSI GT75 TITAN

I need power and lots of it. As a Front End Web developer anything less just won’t cut it which is why the MSI GT75 is an outstanding laptop for me. It’s a sleek and futuristic looking, high quality, beast that has a touch of sci-fi flare about it.

Emily Tyson

MSI GE63 Raider

If you’re looking to invest in your next work horse laptop for work or home use, you can’t go wrong with the MSI GE63.

Laura Johnston

MSI GS65 Stealth Thin

If you can afford the price tag, it is well worth the money. It out performs any other laptop I have tried for gaming, and the transportable design and incredible display also make it ideal for work.

Andrew Teoh

Brother MFC-L9570CDW Multifunction Printer

Touch screen visibility and operation was great and easy to navigate. Each menu and sub-menu was in an understandable order and category

Louise Coady

Brother MFC-L9570CDW Multifunction Printer

The printer was convenient, produced clear and vibrant images and was very easy to use

Edwina Hargreaves

WD My Cloud Home

I would recommend this device for families and small businesses who want one safe place to store all their important digital content and a way to easily share it with friends, family, business partners, or customers.

Featured Content

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?