Of PHP, Facebook’s HipHop and C++
Facebook announced its brand new code transformer, boosting php’s performance by a factor of 2 and also reducing memory consumption (their measurements).
This new beast is called HipHop. According to the announcement:
“Overall, HipHop allows us to keep the best aspects of PHP while taking advantage of the performance benefits of C++. In total, we have written over 300,000 lines of code and more than 5000 unit tests. All of this will be released this evening on GitHub under the open source PHP licence.”
Who knows me also knows that though I’m working with it on a daily basis, I’m not a big fan of PHP – but PHP has never been slow among the scripting languages. It was always one of the fastest in the league, so boosting its performance even further, as I see it isn’t vital. Companies with huge PHP codebases will benefit a little of a speedup, but I think there aren’t many web applications with php as the bottleneck in performance. It’s almost always the database, some unoptimized webpages (many separate static assets, underoptimized images, etc.). For a 2-seconds loading page maybe php accounts for 500 msec, let’s double its performance with HipHop, now the page will load in 1.5 seconds – not such a big win. Of course, there is another side to it – the server side. Better performing code means more cpu cycles for other stuff, so basically this could end in buying less front-end app servers – but again, for a big company, this is not that big of a deal. Servers are cheap compared to the price of bad technology, and php is very hard to use as the base of good architecture. It can be done, but it’s not trivial, the language itself can be a pain in the a*s.
Also, keep in mind that compiling php to a binary can mean additional hickups during deployment (and one of PHP’s major charms is that its deployment is trivial). HipHop is also said to boast an own web server – well, I’d like to see about its features, performance, how well is it tested, does it support the same old rewrite rules, load balancing, etc. as apache or lighttpd?
HipHop is not a new thing, the python universe knows Psyco, Cython and Pypy well, these beasts are based on the same concept and the experience is that your mileage regarding performance boosts may and will vary a lot. I’m not expecting miracles from HipHop, it could mean a huge improvement if PHP was mainly used for scientific or cpu-heavy long calculations, but that’s rarely the case.
If anyone has a lot of free time, I’d suggest improving PHP’s syntax and internal consistency instead of focusing on its performance – if PHP was built only now, I’d call this premature optimization.
And again – on the other hand, speeding up php could mean some speedup in the “global internetz”, as a major part of the webpages are on a php engine, so the mass-effect could occur.
Anyway, I don’t see myself hasting to fire up HipHop on any of my servers – I’d rather spend my time refactoring some old code or changing technologies.
Additional comments powered by BackType


No comments
Trackbacks/Pingbacks