Wednesday, February 3, 2010

PHP Creator Asks, Is Facebook's HipHop Just a "Nifty Trick"?

Earlier this week, we pinged PHP creator Rasmus Lerdorf about the implications of HipHop, the new PHP runtime that Facebook just open-sourced.



Using ReadWriteWeb as an example, he goes into great detail about how speeding up PHP isn't simply a matter of finding a single magic bullet. Lerdorf contends that true optimization comes down to attacking the mundane inefficiencies that sneak into sites of all sizes - even suggesting free tools for PHP devs to use - before a solution such as HipHop is considered.


Sponsor



Additional reporting by RWW journalist Mike Melanson.



But first, for an overview of what HipHop is (Facebook's rewrite of the PHP runtime) and what it does (translates PHP to C++ and compiles it with g++), check out our growing archive of HipHop posts or watch this video from Facebook:





Lerdorf begins his assessment of the project on a positive note. "I think it is a cool project and it will certainly be a good option for some sites," he wrote to us in an email.



"The effectiveness is going to depend a lot on the type of code it is used on. Like similar projects such as Psyco, Cython, Pypy and ShedSkin in the Python world, results vary greatly."



However, he continued to say that raw execution speed was "not a significant factor" for many applications. "Even if you double the execution speed of something that is 10% of your overall request cost, that is only a 5% overall improvement. If on every request you are hitting memcache/postgresql/mysql 10 times and spending a lot of time in system calls, don't expect miracles from HipHop."



Calling the code translator "a nifty trick," Lerdorf worries that some developers will see HipHop as "some kind of magic bullet" for site performance. Noting the amount of hype he's seen lately about the new runtime, Lerdorf wrote, "I'd love to see those same people get excited about basic profiling and identifying the most costly areas of an application. Speeding up one of the faster parts of your system isn't going to give you anywhere near as much of a benefit as speeding up, or eliminating, one of the slower parts of your overall system.



"People generally don't bother doing even the most basic site optimizations. PHP execution speed is usually quite far down the list if you sit down and profile the end-to-end series of HTTP requests that lead to the final page in a broswer..." At that point, Lerdorf was kind enough to give us a run-down of site issues with ReadWriteWeb.com that we dutifully passed on to our new and often beleaguered webmaster.



"These are relatively minor and very common things, but they all contribute to your users' perceived performance of your site. And that's just the frontend. If I sat down with a profiler and looked at your backend I predict I would find similar inefficiencies."



In a word, Lerdorf is telling us all to not get too excited about the "nifty trick" that is HipHop until the runtime is the biggest thing that's stopping a site from being as fast as possible. Given Facebook's engineering focus, we can imagine that the site's been pretty well optimized and HipHop gives enough efficiency to give users a faster front end while also using fewer server resources.



Lerdorf ended by suggesting Yahoo's YSlow and Google's Page Speed for analyzing front-end issues, and he recommended Valgrind's Callgrind for low-level back-end profiling and XDebug for userspace PHP profiling.


Discuss





http://bit.ly/9yh7Mv

No comments:

Post a Comment