Slide 1

Slide 1 text

HHVM? Huh?

Slide 2

Slide 2 text

Where did it start?

Slide 3

Slide 3 text

» Facebook had the "problem" of being too busy

Slide 4

Slide 4 text

» Facebook had the "problem" of being too busy » Hip Hop Compiler (hphpc)

Slide 5

Slide 5 text

» Facebook had the "problem" of being too busy » Hip Hop Compiler (hphpc) » Compiles PHP to C++

Slide 6

Slide 6 text

» Facebook had the "problem" of being too busy » Hip Hop Compiler (hphpc) » Compiles PHP to C++ » Hip Hop Virtual Machine (HHVM)

Slide 7

Slide 7 text

» Facebook had the "problem" of being too busy » Hip Hop Compiler (hphpc) » Compiles PHP to C++ » Hip Hop Virtual Machine (HHVM) » JIT (Just In Time) Compiler

Slide 8

Slide 8 text

So what is it?

Slide 9

Slide 9 text

» Complete custom implementation of PHP

Slide 10

Slide 10 text

» Complete custom implementation of PHP » Can act as server or run on Apache with FCGI

Slide 11

Slide 11 text

» Complete custom implementation of PHP » Can act as server or run on Apache with FCGI » Can also run from command line

Slide 12

Slide 12 text

» Complete custom implementation of PHP » Can act as server or run on Apache with FCGI » Can also run from command line alias composer='hhvm /usr/local/bin/composer'

Slide 13

Slide 13 text

How does it work?

Slide 14

Slide 14 text

» Compiles PHP to HHVM bytecode

Slide 15

Slide 15 text

» Compiles PHP to HHVM bytecode » Easier to translate to native code

Slide 16

Slide 16 text

» Compiles PHP to HHVM bytecode » Easier to translate to native code » Can be interpreted by CPU

Slide 17

Slide 17 text

» Compiles PHP to HHVM bytecode » Easier to translate to native code » Can be interpreted by CPU » Cache implemented as SQLite DB on disk

Slide 18

Slide 18 text

Comparison time!

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

Compatibility

Slide 24

Slide 24 text

» 100% compatibility with 18 of the most popular frameworks/libraries

Slide 25

Slide 25 text

» 100% compatibility with 18 of the most popular frameworks/libraries » Average compatibility of 97.49%

Slide 26

Slide 26 text

» 100% compatibility with 18 of the most popular frameworks/libraries » Average compatibility of 97.49% » List checked: assetic,codeigniter,composer,doctrine2, drupal,facebookphpsdk,guzzle,idiorm,joo mla,joomlacms,klein,kohana,laravel,mage nto2,mediawiki,mockery,monolog,mustache ,paris,pear,phpbb3,phpmyadmin,phpunit,p roxymanager,ratcher,reactphp,silverstri pe,slim,symfony,twig,vfsstream,yii,zf2

Slide 27

Slide 27 text

How to use HHVM

Slide 28

Slide 28 text

Command Line hhvm /path/to/script.php

Slide 29

Slide 29 text

Daemon hhvm --config /path/to/config.hdf --user www-data --mode daemon

Slide 30

Slide 30 text

Daemon Config VirtualHost { * { Pattern = .* RewriteRules { dirindex { pattern = ^/(.*)/$ to = $1/index.php qsa = true } } } }

Slide 31

Slide 31 text

FCGI: Apache cd /path/to/your/apache/conf ln -s ../mods-available/mod_proxy.load mods-enabled/mod_proxy.load ln -s ../mods-available/mod_proxy.conf mods-enabled/mod_proxy.conf ln -s ../mods-available/mod_proxy_fcgi.load mods-enabled/mod_proxy_fcgi.load httpd.conf ProxyPass / fcgi://127.0.0.1:9000/path/to/your/www/root/goes/here/ VirtualHost ProxyPassMatch ^/(.*.php(/.*)?)$ fcgi://127.0.0.1:9000/path/to/your/www/root/goes/here/$1

Slide 32

Slide 32 text

FCGI: Nginx root /path/to/your/www/root/goes/here; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /path/to/your/www/root/goes/here$fastcgi_script_name; include fastcgi_params;

Slide 33

Slide 33 text

The magic of Hack

Slide 34

Slide 34 text

Hack: Example

Slide 35

Slide 35 text

» Easy to move over to hack as it is basically PHP with type annotations

Slide 36

Slide 36 text

» Easy to move over to hack as it is basically PHP with type annotations » Contains new collections (Vector, Set, Map, etc)

Slide 37

Slide 37 text

» Easy to move over to hack as it is basically PHP with type annotations » Contains new collections (Vector, Set, Map, etc) » Contains new Special-Cased functions

Slide 38

Slide 38 text

» Easy to move over to hack as it is basically PHP with type annotations » Contains new collections (Vector, Set, Map, etc) » Contains new Special-Cased functions » invariant, invariant_violation, invariant_callback_register, fun, class_meth, inst_meth, meth_caller

Slide 39

Slide 39 text

Hack: invariant

Slide 40

Slide 40 text

Hack: fun

Slide 41

Slide 41 text

The End