20
How will it effect the future of WordPress?

Hhvm and wordpress

Embed Size (px)

Citation preview

How will it effect the future of WordPress?

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

By the numbers

0

0.15

0.3

0.45

0.6

WP 1 WP 2 WP 3 WP 4

HHVM FPMAv

g pa

ge lo

ad ti

me

WP installs

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

Things that go bump

http://xkcdsw.com/content/img/1218.png

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

Xhprof & XhGui

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/

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