10 ms·
FasterCGI with HHVM
- nikic 13y agoPlease, if you do performance benchmarks, always run them with an opcode cache (PHP 5.5 + opcache would be the obvious choice). Without it your benchmark becomes completely meaningless. I also feel like HHVM devs should be aware of this, so likely the numbers are deliberately misleading. Apart from that, having FastCGI support is of course nice.
- thezilch 13y agoAnd using something like `wrk` and not `ab`...
- stormbrew 13y agoOr at least say upfront if you are or not. I think it's not exactly unreasonable to compare "out of the box" to "out of the box", but it should be clear that's what you're doing. Really I think this sort of thing should be encouragement to make the opcode cache no longer a default-off additional thing. There's no good reason to have a php deployment -- even one that's just for dev purposes -- that doesn't use an opcode cache.
- allanmacgregor 13y agoNot necessarily there applications like Magento that still only run on PHP5.3 so this numbers are actually relevant. And we can agree FastCGI support is nice indeed.
- randartie 13y agoThis post claims that it did: https://news.ycombinator.com/item?id=6925278 https://news.ycombinator.com/item?id=6925278
- jayzalowitz 13y agoOnce again, I request that HHVM adopt a hippopotamus as the mascot.. #TeamHipHopPopotamus
- girvo 13y agoMy rhymes are bottomless...
- MAGZine 13y agoHas something changed? The last time I went to use hiphopvm it didn't even have proper support for php 5.4 (broken namespacing and traits, too I believe). That said, it was basically unusable.
- kmavm 13y ago(HHVM alum here). Sorry you had a tough time. What's changed is that time has passed, and the HHVM team has put a lot of effort into closing the compatibility gap. If you are aware of a bug with namespaces or traits, let us know at https://github.com/facebook/hhvm/issues https://github.com/facebook/hhvm/issues http://www.hhvm.com/blog/875/wow-hhvm-is-fast-too-bad-it-doesnt-run-my-code http://www.hhvm.com/blog/875/wow-hhvm-is-fast-too-bad-it-doe...
- jtreminio 13y agoDo you mean Hip Hop PHP, not VM?
- coldtea 13y agoWhy should it have "proper support for php 5.4"? It's a quite recent version, and it's not really needed anyway at this moment. 99% of projects out there, from Symphony to Wordpress, are still PHP 5.3 compatible. I don't know any major project requiring traits for example.
- ptarjan 13y agoWhen did you try it last? We spun up a whole team (which I'm on) who's entire goal is to make all of the world's PHP code runable on HHVM. All of the top 20 PHP frameworks work on HHVM now. http://www.hhvm.com/blog/1499/locking-down-for-performance-and-parity http://www.hhvm.com/blog/1499/locking-down-for-performance-a...
- kodablah 13y agoI wish they would be implementing more of the runtime support in PHP itself. Why not make the FastCGI[1] code in pure PHP (like others have[2])? I understand if they don't feel PHP is the best language for daemons, but it would allow so many other developers to use, modify, and comprehend the implementation. I think HHVM suffers from a serious lack of dogfooding. 1 - https://github.com/facebook/hhvm/tree/master/hphp/runtime/server/fastcgi https://github.com/facebook/hhvm/tree/master/hphp/runtime/se... 2 - https://github.com/kakserpom/phpdaemon/tree/master/PHPDaemon/Servers/FastCGI https://github.com/kakserpom/phpdaemon/tree/master/PHPDaemon...
- Scaevolus 13y agoMiniscule improvements are worth large amounts of money at Facebook's scale. They have an excellent team of C++ and compiler developers working on HHVM, and they see no reason to waste time attempting something in PHP when they could make it run faster in native code without much more initial effort (and probably less effort over time).
- kodablah 13y agoI would hope that their JIT'ing VM could come close to native performance (and rarely faster as tracing JITs can occasionally be). It's about drawing the line somewhere. It's like choosing between Phalcon and Symfony. I understand their internal needs at Facebook, but considering the effort they are putting in to make non-Facebook codebases work I don't think it's too much of a stretch to implement some of the runtime in PHP.
- ptarjan 13y agoWhenever we can, we build extensions in PHP https://github.com/facebook/hhvm/tree/master/hphp/system/php https://github.com/facebook/hhvm/tree/master/hphp/system/php Many of the older extensions that were imported back in the HPHPc days are in C since they were much easier to port from php-src if we didn't have to translate the language. As for why this was't in PHP, two reasons. It was easier to stay in the language since our event loop code was already in C++, and most of the gains we get from writing library code in PHP comes from not having to cross a language barrier from userland code. The event loop is not the best place for that.
- jkopczewski 13y agoHi, my name is Julius and I performed the said benchmark while being an intern at FB. Yes, we used opcode cache in PHP. I definitely don't consider myself to be an expert on PHP configuration. I used the default settings. I was obviously also very suspicious of the results that we got. To the extent, that I consulted a few people about what could be improved about the PHP setup. I remember opcode cache was the first thing I checked, since it's something everyone knows and talks about. It was turned on. I will update the blog post first thing tomorrow (sorry guys, it's the middle of a night here in Poland, so don't feel like doing it right now). Cheers.
- jkopczewski 13y agoThe only other place where I could have possibly screwed up the results is compilation. I had to build PHP from source, since I wanted to have the "latest greatest" and CentOS has dated packages at times. Though again, I remember just following the official instructions. If you would like to have the test re-run, you'll have to harass some real FB engineers, since the test was performed on a devbox that I don't have access too anymore. You're also more then welcome to try it yourself and post some alternate benchmarks. I think I can promise to link to your results from the blog post.
- allanmacgregor 13y agoWould it be possible to get the actual test files? I would love to do my own benchmarks against my current stack
- sigil 13y agoThere are a couple of important features still missing from the initial implementation. The most notable is support for local UNIX sockets. At present, only less performant (however more flexible) TCP sockets are available. This note hints at a missed opportunity to employ what some like to call "unix factoring": the listen(2) call can occur outside of your FastCGI worker program, which then only has to call accept(2) on the inherited descriptor, and implement the FastCGI protocol. Why do it this way? 1. Beyond the accept(2) call, your worker program is now network agnostic. 2. Guess what, you can now test your worker program by feeding it FastCGI protocol data directly on stdin. Just add a mode that uses stdin instead of the fd returned by accept(2). 3. For easy TCP socket support, run your worker under something like this tiny program [1]. For easy Unix Domain socket support, run your worker under something like this tiny program [2]. Your worker program doesn't change because the networking concern has been separated out. 4. If you want, you can put a program which keeps a preforked worker pool between the the listener program and the worker program. This separates out the concurrency concern. 5. No real performance downside; listen(2) is called once for a long-running server process. [1] tcplisten : https://gist.github.com/acg/4211098 https://gist.github.com/acg/4211098 [2] unixlisten : https://gist.github.com/acg/8016689 https://gist.github.com/acg/8016689
- ptarjan 13y agoI'd happily take a pull request if you want to get it working.
- spencerhakim 13y agoReally want to try this, but no public key provided to verify the packages?
- thomaslutz 13y agoYeah, this is a bit disappointing.
- kayoone 13y agohm cant seem to get it to work with Nginx under Ubuntu 12.04 I followed the instructions and the hhvm seems to be running fine but i get a NOT FOUND from nginx. I basically just changed fastcgi_pass 127.0.0.1:9000; (was php5-fpm) before but the hhvm logfiles are still empty. Any heads up ? Trying this on a Symfony 2.4 project.