Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
HipHop for PHP in Production at Hyves (hyvesblogonproductdevelopment.blogspot.c...)
79 points by ma2rten on Dec 22, 2011 | hide | past | favorite | 30 comments


How does hiphop performance compare to fastcgi + opcode-cache (with stat turned off)

I remember reading that on paper it seems it should be faster but in reality not so much.

Ah okay, hiphop IS faster:

http://php.webtutor.pl/en/2011/05/17/drupal-hiphop-for-php-v...

   environment [req/sec][ms/req][%]
   Regular PHP 	15.10 	66.242 	100%
   PHP + APC 	46.90 	21.321 	310%
   HipHop  	77.01 	12.985 	510%  (1.6x faster than apc)
http://huichen.org/en/2010/06/wordpress-3-benchmark/

   wp3+php+apc  30.86   32.400  
   wp3+HipHop   43.50   22.990        (1.4x faster than apc)
Maybe multicast could be used on the intranet for distribution - but 500mb monolithic binaries sounds kinda insane.


I work for facebook and I worked on the deployment of these large hiphop binaries of our code base. We considered multiple options - binary diffs, multicast, etc. The problem with multicast is that it's hard to configure and maintain in our complex cross region datacenter setup that has to travel through other peering networks.

We ended up with a torrent deployment system that scales beautifully.


We ended up doing exactly the same, I wrote a tracker for the bittorrent deploy system that is aware of our network topology and able to transport these 500Mb binaries to our frontend pool in < 3mins (300+ servers)

The tracker is opensource: https://github.com/hyves-org/p2ptracker

We're working on open sourcing more moving parts of our deploypipeline.

I'd be interested to compare notes on your system ?


For those who don't know, Hyves is the largest social networking site in the Netherlands, although in recent times they're facing fierce competition from Facebook. It's ironic that Facebook is indirectly helping them with HipHop.


That's the beauty of open source. Let the best implementation win, not the competitor with the most marketing money. I have had this conversation with older business-type people who don't quite understand why we might want to make certain aspects of our code available, they just see it as enabling competition but everytime a competitor has come along it just energizes us to innovate harder and over the years I can look back and see that some of our best work was done in the months after a new potential competitor appeared.


I work at Hyves and wrote this article. If you have any questions on our use of Hiphop, please ask here and I will try to answer any questions.


he Willem, you still work there? First time I see Hyves on first page at HN. I didn't even know they were writing a blog on product development. How's it working? Are you writing articles alone, or are several guys writing on what they are working on? Very good idea in any case.

Anyways, good luck with the fight against Facebook ;-)

BTW, if you don't recognize me, I was the only frenchman working there at the time...


Ti toumhi! Don't worry, how can I forget the only Frenchie at Hyves?


hehe good - but it seems you eluded my questions ;-)


I am curious if you have looked at Quercus, quercus.caucho.com as well? This is PHP compiled/interpreted to JVM.


We did not really consider it, as we have few experienced Java developers and had no need to make Java and PHP code work together.

The Hiphop project started of because one engineer thought it was "really cool" and when he was able to produce impressive benchmarks, we put some more company effort into it.


Is there a list of functions and features that doesn't work with Hiphop?


Namespaces don't work very well, all functions that create dynamic code (code that is not known at compile time) don't work (eval(), create_function(), preg_replace() with 'e' modifier).

Don't define constants where the name of the constant is a variable, as in "define($key, $value)"

Don't use "current($a)" to get the first element of an array $a, but use "reset($a)". current returns whatever element the internal array pointer points to, and PHP changes that pointer in crazy/undefined ways. Hiphop has a saner way to handle that pointer, but it's not the same as in PHP so your code might break if it's dependent on the specificities of PHP. In general use current only in case you are explicitly handling the internal pointer (that is, you are also calling reset/next).

Under the compiled version of hiphop, class_exists returns true for (almost) all the classes even if you haven't already included the file where they are defined, since they are all statically compiled.

Don't rely on destructors being called at the end of the requests: under hiphop they aren't. So either the object happens to be destructed during request execution (due to its reference count going to 0), in which case the destructor is called, or the object is garbage collected at the end of the request and its destructor is just ignored.

There are some differences in the handling of SOAP errors in Hiphop.

This will give a fatal error in Hiphop but not PHP: $z = null, $z[0] = "foo";

You can consult these Hiphop docs: https://github.com/facebook/hiphop-php/raw/master/doc/incons... and https://github.com/facebook/hiphop-php/raw/master/doc/incons... for a list of other inconsistencies between PHP and Hiphop.


is it easy to add an extension to hiphop? i.e mongo.so


I'm wondering, if several engineers spent months porting their php code to hiphop, wouldn't they be better off just rewriting critical parts of their code base to c++?


If HipHop supports 99% of PHP 5.3, then it took them months to change 1% of their code. Changing any more than that would have obviously taken longer, especially to a whole other language.


I would like to elaborate a bit on this. Currently, Hiphop supports 99% of the PHP 5.3 features. When we started working on Hiphop, less was supported.

Stuff like closures, eval(), create_function(), constants with dynamic names (e.g. defining constants from an array) and class destructors were all not supported. Some more subtle stuff: you cannot use current() to get the first element of an array in Hiphop, class_exists() always returns true.

We also had to port our custom PHP extensions.

Finally, we spend a lot of time on related stuff such as precompiling all Smarty templates (so that the generated PHP gets translated to C++ too), using Hiphop's daemon system and setting up compile, build and deploy systems.


Willem, how much of the performance improvement was related to Smarty templates being compiled to C++ vs. the application itself?


We did not measure this separately. With Hiphop, you compile a bunch of PHP files to a binary executable file. Once you have this file, you cannot load any new PHP files like you can with vanilla PHP. So including the Smarty templates is kind of mandatory.


Aha I see. Thnx for the follow up.


Please god no! Have you seen the type of code written in PHP? Do you really want more shitty C++ code to be created???


If I were making the decision on where to move my PHP code now, would Phalanger be a better alternative than HipHop?

---

http://tirania.org/blog/archive/2011/Dec-21.html

"This year the Phalanger guys released Phalanger 3.0 which now runs on Mono (previously they required the C++/CLI compiler to run). Phalanger's performance is impressive as it is just as fast as the newly announced Facebook HipHop VM for PHP. The major difference being that Phalanger is a complete PHP implementation and the HipHopVM is still not a complete implementation." - Miguel de Icaza

Phalanger http://phalanger.codeplex.com/ http://www.php-compiler.net/


Wtf does it mean to be a complete PHP implementation? As far as I know, there's no standard specification for the whole language, there's not even an EBNF grammar. There's no ISO or ANSI effort to standardize it either.


Perhaps feature compatibility with a particular version of the normal PHP interpreter? This would be the opposite of HipHop's lack of support for certain PHP features.

The referenced post states "It is so complete that it can run both MediaWiki and WordPress out of the box."


You would use the default interpreter (http://www.php.net) as the golden standard, since no specification for the language exists.


They have a code base of 3.5M LOC and 10M users.


Complexity is the root of all evil. There's been some publications [1] that compare revenue per employee which sometimes is interesting. For technologists, it might actually be interesting to see LOC per User. Hyves seems to run at 1/3rd of a line per user; is that high or low? Any published stats like that?

[1]: http://37signals.com/svn/posts/2283-ranking-tech-companies-b...


And shrinking... (members that is)

Facebook used to be pretty unknown here in the Netherlands, but is growing in popularity, with Hyves losing. They were acquired last year by a newspaper and media conglomerate Telegraaf.


They are also competing with Facebook. Ironic that they are now dependent on their competitor's technology.


Great to read about other large-scale users of HipHop, thanks for posting. The last graph on CPU usage says it all really.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: