HHVM
@richardtape
“It was a high-risk, high-reward
bet. We now operate at such an
enormous scale, we have to
take enormous risks in
order to survive”
Jay Parikh, Facebook engineer
$
HipHop for PHP (HPHPc)
Wait. Binary? Executable? What?
YOU SAID COMPILE!!
A new challenger approaches
Hip Hop Virtual Machine
Seriously. That’s actually what HHVM stands for.
HHVM is a “process virtual machine” using just-in-time compilation
YOU SAID COMPILE!!
Don’t panic!
Process Virtual Machine?
AKA an Application Virtual Machine. (Oh that’s much better.) Or a Managed Runtime Environment (Who makes these things up?)
In real words it means that your code is completely abstracted away from the underlying platform which in turn means the same code will give the same results, regardless of platform.
Hip Hop Byte Code
I promise you I’m not just making up words. Again, that’s actually it’s name.
PHP (and ‘Hack’) are converted into Hip Hop Byte Code (HHBC) which is then converted into machine code and then executed.
STOP USING ACRONYMS AND MADE-UP WORDS AND SHOW ME SOMETHING
If you can write PHP, you can use HHVM
If you can’t write PHP, you can learn Hack – a gradual typed language – and use HHVM
"After all, facts are facts, and although we may quote one to another with a chuckle the words of the Wise Statesman, 'Lies--damned lies--and statistics,' still there are some easy figures the simplest must understand, and the astutest cannot wriggle out of.”
Leonard Henry Courtney, 1895
OK, numbers are good, but does performance REALLY matter?
Every -100ms = +1% in revenue (Amazon, Walmart). Case closed.
Who in the WordPress managed-hosting world is supporting HHVM?
But, what if I’m running my own good ship lollipop?
Well, calm down Shirley Temple. You’re bright eyes are almost certainly covered.
Pretty much every main Linux distro is supported
Q: How easy is it to set up from scratch?
A: Very. 15 minutes. If you’re using nginx or apache, the HHVM setup routine “just works” out of the box.
Q: How easy is it to switch from PHP-FPM?
A: Depends. But probably very. 20 minutes. The ‘hard’ part will be adjusting your existing config, but HHVM’s default config is an almost drop-in replacement.
What about my PHP Extensions?
https://github.com/facebook/hhvm/wiki/Extensions
A lot of commonly used extensions (most, I would say) are supported out of the box. The big one not supported ootb is pgsql but this has a third-party extension (yay open source)
I haven’t run into any extension issues, but they have an API for you to write your own:
https://github.com/facebook/hhvm/wiki/Extension-API
Any gotchas with WordPress-y stuff?
Yes. Sadly. But they’re becoming fewer and fewer. These 3 commits fixed a whole bunch of things:
https://core.trac.wordpress.org/ticket/27231
https://core.trac.wordpress.org/ticket/29217
https://github.com/facebook/hhvm/commit/516e149377edcd10cbb8f208a2f9545485488603
The big gotchas are now - as far as I can tell - entirely plugin/theme based (surprise!)
So… Plugins / Themes?
HHVM does not have 100% compatibility with PHP yet. Its aim is for parity. So, if a plugin uses some unsupported stuff then the world ends.
That being said, if it isn’t supported, it’s probably not the best code out there so may be worth considering a different option.
Basic gotcha: long-running tasks on a wp-cron seem to break things. i.e. backup plugins. *on bad hosting
How about Plugins / Themes?
https://wordpress.org/plugins/wordpress-backup-to-dropbox/ (long wp-crons)
https://wordpress.org/plugins/wp-all-import/ (php://filter usage … bit weird)
Can bring your site down on HHVM. Sad Panda. (But you can run PHP-FPM as a fallback…)
Is it ready for prime-time?
Facebook think so. But then they would, wouldn’t they?
My personal opinion;
On a small site where you control everything: yes
On a managed host where it’s controlled for you: yes
Everywhere else: it needs some serious consideration right now. But as time goes on, it becomes more and more a genuinely viable option.
Who are you, again?
Richard Tape, a developer at UBC – The University of British Columbia
@richardtape on Twitter
Managed WordPress hosts with HHVM available
https://github.com/wpengine/hgv
https://pagely.com/blog/2014/06/run-hhvm-pagely/
https://www.siteground.com/blog/hhvm/
https://www.dreamhost.com/hosting/wordpress/
Or DIY
From scratch: https://richardtape.com/2015/02/14/setting-wordpress-hhvm-digital-ocean/
If you already have PHP-FPM: https://richardtape.com/2015/03/07/from-php-to-hhvm/
References;
HHVM
https://github.com/facebook/hhvm
http://hhvm.com/ (how much did THAT cost?!)
Hack
https://github.com/facebook/hhvm/tree/master/hphp/hack
WordPress
https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/
Other
https://codeascraft.com/2015/04/06/experimenting-with-hhvm-at-etsy/
http://www.phoronix.com/scan.php?px=MTg3ODY&page=news_item
http://radar.oreilly.com/2009/06/bing-and-google-agree-slow-pag.html
http://alistapart.com/column/performance-matters
https://rtcamp.com/tutorials/php/hhvm-with-fpm-fallback/
http://brianjackson.io/speed-up-wordpress/
https://ckon.wordpress.com/2015/08/09/wordpress-4-3-benchmark-hhvm-vs-php7/