Upgrade to Pro — share decks privately, control downloads, hide ads and more …

HHVM for PHP and Hack

34be88398f623c109b61d23e8215bd23?s=47 Mariusz Gil
September 27, 2014

HHVM for PHP and Hack

34be88398f623c109b61d23e8215bd23?s=128

Mariusz Gil

September 27, 2014
Tweet

Transcript

  1. HHVM HACK PHP + + Mariusz Gil

  2. None
  3. None
  4. BE FAST AT SCALE

  5. None
  6. None
  7. None
  8. None
  9. None
  10. None
  11. None
  12. None
  13. IS SLOW

  14. ISN’T FAST

  15. CODE INTERPRET TO OPCODE OPCODE EXECUTION OPCODE CACHE

  16. SOLUTION NEEDED

  17. 2008

  18. 2010

  19. 2010

  20. SUCCESS 50% CPU USAGE REDUCTION

  21. CODE TRANSFORM CODE TO C++ COMPILE WITH G++ EXECUTE NATIVE

    CODE
  22. FAILURE?

  23. 2010

  24. 2013

  25. HHVM OPEN SOURCE VIRTUAL MACHINE FOR PHP

  26. HHVM OPEN SOURCE VIRTUAL MACHINE FOR PHP PHP5 SUPPORT* HACK

    SUPPORT JIT COMPILATION HHVM NATIVE INTERFACE FAST CGI SUPPORT CLI SUPPORT HPHPD
  27. CODE TRANSFORM CODE HHBC OPTIMIZE TRANSLATE HHBC TO X86-64 CODE

    EXECUTE NATIVE CODE
  28. cat ./phpversion.php <?php ! var_dump(phpversion()); ! ! php -f ./phpversion.php

    string(16) "5.5.9-1ubuntu4.4" ! ! hhvm -f ./phpversion.php string(11) "5.6.99-hhvm"
  29. cd/var/www/webapp; ! hhvm --mode server -vServer.Type=fastcgi -vServer.FileSocket=/var/run/hhvm/hhvm.sock -vAdminServer.Port=9001 ! !

    root /var/www/webapp; fastcgi_pass unix:/var/run/hhvm/hhvm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params;
  30. alias composer="hhvm -v ResourceLimit.SocketDefaultTimeout=30 -v Http.SlowQueryThreshold=30000 /usr/local/bin/composer”

  31. JIT OPTIMIZATIONS

  32. EXTENSIONS API

  33. None
  34. HACK LANGUAGE FOR HHVM THAT INTEROPERATE SEAMLESSLY WITH PHP

  35. HACK LANGUAGE FOR HHVM THAT INTEROPERATE SEAMLESSLY WITH PHP TYPE

    ANNOTATIONS TYPE ALIASING GENERICS NULLABLE TYPES COLLECTIONS CONTINUATIONS LAMBDAS ASYNC PROGRAMMING SHAPES TUPLES
  36. <?hh ! class Mailbox<T> { private ?T $data; ! public

    function __construct() { $this->data = null; } ! public function put(T $mail): void { $this->data = $mail; } ! public function check(): ?T { if ($this->data !== null) { return $this->data; } return null; } }
  37. cat ./test.hh <?hh ! function f(): Vector<T> { return 'not

    an Vector<T>'; } ! ! hh_client /home/vagrant/test.hh:3:22,22: You probably forgot to bind this type parameter right? Add <T> somewhere (after the function name definition, or after the class name) Examples: function foo<T> or class A<T> /home/vagrant/test.hh:4:10,27: Invalid return type /home/vagrant/test.hh:3:15,20: This is an object of type Vector /home/vagrant/test.hh:4:10,27: It is incompatible with a string
  38. PHP NG

  39. sapi/cli/php -v PHP 7.0.0-dev (cli) (built: Sep 25 2014 22:05:10)

    Copyright (c) 1997-2014 The PHP Group Zend Engine v2.8.0-dev, Copyright (c) 1998-2014 Zend Technologies
  40. CODE TRANSLATE ZEND BYTECODE TO LLVM COMPILE TO MACHINE CODE

    EXECUTE MACHINE CODE
  41. HIPPYVM IS PHP IMPLEMENTATION USING PYPY

  42. DEMO

  43. 0 0,4 0,8 1,2 1,6 bench heapsort binary trees php

    5.5.9 php-ng hhvm
  44. SILVER BULLET

  45. NOPE! CODE IS NOT YOUR BOTTLENECK, DATABASE AND STORAGES ARE

  46. ARCHITECTURE AND CAREFULL PROGRAMMING!

  47. None
  48. NO CODE IS FASTER THAN NO CODE

  49. VARNISH

  50. @mariuszgil THANKS! joind.in/talk/view/11837