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?
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
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)
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
How do I invoke it?
• Command line: hhvm foo.php
• Webserver, port 80/443
• FastCGI, behind apache/nginx
• Debian packaging: apt-get install hhvm
Where does HHVM fit?
Nginx
Apache/FPM/FastCGI
Mysql
Memcached
PHP/WP
browser
HHVM
Mysql
Nginx
PHP/WP
Memcached
browser
Why is this important?
• HHVM is faster
• Less time processing PHP means faster websites
• Sites that are not very cacheable become more performant
More numbers
0
0.4
0.8
1.2
1.6
1 2 5 8 10 15 20
HHVM FPM Apache
Number concurrent requests
Avg
load
tim
e (s
ecs)
One WP, different PHP processor tests
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.04Apache 10.04
One WP, different PHP processor testsAv
g lo
ad ti
me
(sec
s)
Number concurrent requests
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
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
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
Resources• hhvm.com
• github.com/facebook/hhvm
• docs.hhvm.com/manual/en/intro.xhprof.php
• github.com/preinheimer/xhprof github.com/phacility/xhprof
• www.sitepoint.com/the-need-for-speed-profiling-with-xhprof-and-xhgui/