The document discusses how HHVM (HipHop Virtual Machine), a just-in-time compiler created by Facebook, can improve the performance of PHP-based websites like WordPress by compiling PHP to bytecode faster than traditional PHP processing. It provides benchmarks showing HHVM's performance advantages over PHP-FPM and describes tools like XHProf that can help optimize WordPress sites to take advantage of HHVM's capabilities. While HHVM has risks with poorly coded themes/plugins, its performance gains make it worth considering as an alternative PHP processor.
2. What are we talking about?
• The middle layer of page processing (PHP)
• How this effects you and your WP development
• WP, PHP, plugins, themes, BuddyPress
• What tools to I need to use HHVM?
3. Why change PHP?
• PHP processing is slow
• Run time compilation means slow
• Existing op-code caches do an okay job (APC, eAccelerator)
• PHP is loosely type and a ‘scripting language’
• Resulting in poorly coded habits, themes and plugins
• Resulting in less that optimal performance
• Syntax errors fatal crash at runtime
4. What’s the big deal?
• PHP mainstream has not spent a lot of time
optimizing it’s core, therefore leaving it to become
slow
• PHP-FPM has been the FastCGI PHP processor of
choice
• Along comes HPHPc (HipHop for PHP) interpreter
and compiler created by Facebook (~2009 - 2013)
• Now comes HHVM (HipHop Virtual Machine ~2012)
5. How is HHVM better?
• JIT - just in time compilation of code to bytecode
• Convert PHP to intermediate byte code then
machine code
• Even faster by enabling RepoAuthoritative mode
• Tools to detect syntax errors ahead of time?
• More strict typed PHP
6. How do I invoke it?
• Command line: hhvm foo.php
• Webserver, port 80/443
• FastCGI, behind apache/nginx
• Debian packaging: apt-get install hhvm
7. Where does HHVM fit?
Nginx
Apache/FPM/
FastCGI
Mysql
Memcached
PHP/WP
browser
HHVM
Mysql
Nginx
PHP/WP
Memcached
browser
8. Why is this important?
• HHVM is faster
• Less time processing PHP means faster websites
• Sites that are not very cacheable become more
performant
10. More numbers
0
0.4
0.8
1.2
1.6
1 2 5 8 10 15 20
HHVM FPM Apache
Number concurrent requests
Avgloadtime(secs)
One WP, different PHP processor tests
11. Even more numbers
0
0.5
1
1.5
2
1 2 5 8 10 15 20
HHVM 14.04 FPM 14.04 Apache 14.04 Apache 12.04
Apache 10.04
One WP, different PHP processor tests
Avgloadtime(secs)
Number concurrent requests
12. Things that go bump
http://xkcdsw.com/content/img/1218.png
13. Is there risk?
• HHVM + poorly written WordPress themes/plugins
can be unstable and unpredictable
• Why? HHVM compiler is strict and doesn’t support
all of PHP historical coding practices
• Memory leaks in HHVM
• Faster PHP is good, but if it doesn’t work, that’s bad
14. Squeeze the performance
• Xhprof - profiling tool
• Convert PHP to Hack - hh_client (typechecker) and
hackificator
• HHVM RepoAuthoritative mode - compile .php files
in a directory to one sqlite3 file
18. What is WPE doing?
• Labs team investigation and beta with select sites
• Add HHVM to our web stack
• High availability and failover. If/when HHVM fails,
another service does the PHP processing
• Development tools to develop your WP for HHVM
20. Son: Dad, cicadas can jump to China.
Dad: Wow, that’s far, how do that do that?
Son: With their legs.
Dad: Oh
Son: And if the moon was China, they could jump to the moon too.
Dad: Well, of course. You think it’ll make it?
Son: If it really wants to, it will.
Inspiration from a 4 yr old