Tuesday, February 2, 2010

Facebook Gets Faster, Debuts Homegrown PHP Compiler

thefacebook.jpgThe rumors have been flying over what's going on over at Facebook headquarters. The word has been that a PHP team was brought in and made to sign non-disclosure agreements, before discussing a PHP project that has been in development for the past two years. Alex Handy, senior editor of the Software Development Times Blog, predicted last Saturday that Facebook "has rewritten the PHP runtime from scratch," and several anonymous sources have confirmed for us tonight that Facebook has indeed been making some changes to the basic PHP runtime environment.



According to our sources, Facebook has been working on a PHP compiler that will increase speed by around 80% and offer a just-in-time compilation engine that will offer a number of advantages. The project is very similar to Google's Unladen Swallow project, which rebuilt the Python compiler, boosting the speed fivefold and opening the door for multi-language integration.


Sponsor



Richard Crowley, an engineer at OpenDNS who is familiar with the project, told us that David Recordon, an engineer at Facebook, invited him to to the Facebook headquarters for Tuesday moning but wouldn't give a reason. Crowley mused to us that it was likely his PHP skills that got him through the doors and clued us in on what he thinks will be going on behind them.



PHP is normally an interpreted language, which means that every time a user accesses a PHP page, the server needs to take the code and interpret it to produce the final product. A compiler, however, makes this process much quicker, as the code is interpreted before the user ever asks for the page. The problem here is that any time that webpage needs to be changed, the code needs to be recompiled.



Crowley explained to us that the just-in-time compiler Facebook is introducing occupies a middle ground that not only retains the flexibility of PHP as an interpreted language, but offers the speed of compiled languages like C.



Compiling PHP to code a CPU can directly execute certainly has performance implications. It would be silly to alter the workflow to be more like C or C++ by doing all parsing and compilation ahead of time. At the other end of the spectrum, it's slow and out-of-fashion to interpret every statement within the runtime. A JIT (Just In Time) compiler compiles frequently-executed portions of the program to machine code for speed while maintaining the flexibility of interpreted code.


Crowley continued, saying that he expected Facebook to announce a JIT compiler based on the Low Level Virtual Machine, which lays at the heart of Google's Unladen Swallow project.



When we asked what he thought of this style of release - years of secretive development by two lonely coders, likely locked in a deep, dark vault - he said it was typical.



"[Facebook] tends to do giant code dumps," he said. "Facebook tends to build something big, use it, and open source it."



We wish Facebook had made this project open, as we're sure many PHP developers would concur that the efforts would have been much swifter and more beneficial to the public had more folks and a larger team been involved from the outset. And we do wonder about possible duplication of effort from others who may have been working on the same issue.



There are a number of us out here running PHP (ahem!) that could certainly have benefited from the speed boost.



Nonetheless, we're looking forward to see what this does for our PHP browsing experience and how the open-source community reacts to the news. Will the community rally around the new compiler and push PHP into a new realm?


Discuss





http://bit.ly/9jB5u9

No comments:

Post a Comment