HipHop VM:
overclocking Symfony
Vadim Borodavko
vadim.borodavko@gmail.com
HipHop – replacement for Zend PHP

© 2008 – 2013

Vadim Borodavko
01.10.2013

01.08.2013

01.06.2013

01.04.2013

01.02.2013

01.12.2012

01.10.2012

01.08.2012

01.06.2012

01.04.2012

01...
Two ways

HPHPc
•
•

Up to 6x faster than Zend PHP 5.2

No source code in production

Vadim Borodavko
Two ways

HPHPc
•
•
•

Compilation takes long time
Big executable files

Dynamic code

Vadim Borodavko
Two ways

HHVM
•
•
•

JIT-compilation

Dynamic code
Edit – Save – Run

Vadim Borodavko
Two ways

HHVM
•

The need for revision of the existing
PHP-code

Vadim Borodavko
Supported OS

Mint

Ubuntu

CentOS

Mac OS

Debian

Arch

Fedora

Gentoo

FreeBSD
Vadim Borodavko
Supported OS

https://github.com/javer/gentoo-overlay

Vadim Borodavko
Compatibility with PHP

5.4.999-hiphop
PHP 5.5 – to the end of 2013 year

Vadim Borodavko
Compatibility with PHP

5.3 features
•
•
•
•
•

namespaces
late static binding
goto
Closures
ternary operator
Vadim Boroda...
Compatibility with PHP

5.4 features
•
•
•
•
•

traits
$a = [1, 2, 3, 4];
foo()[0]
Closures with $this
(new Foo)->bar()

•...
Compatibility with PHP

5.5 features
•
•
•
•
•

generators
finally*
list() in foreach
empty(expr)
[1, 2, 3][0]

•
•
•

pas...
Compatibility with PHP

Extensions

50+

•
•
•
•
•
•

fileinfo
imagick
intl*
mysqli
tidy
xsl
Vadim Borodavko
PHP language extension
<?hh
class Walk<T as Iterator> {
private T $iterator;
public function setIterator(T $iterator, int ...
PHP language extension

Vadim Borodavko
PHP language extension

Type hinting
private int $count;
protected string $name;
public function setCount(int $count): int...
PHP language extension

Tuples
public $t = tuple(“Symfony”, true);

Vadim Borodavko
PHP language extension

Collections
$keys = Vector<int> {};
$values = Map<int, string> {};
$keys->add($k);

$values[$k] = ...
PHP language extension

Generics, Constraints
class Walk<T as Iterator> {
private T $iter;
public function setIterator(T $...
Operational modes

CLI
•
•
•

PHP CLI: hhvm --php
A bit slower than Zend PHP
JIT-compilation*

Vadim Borodavko
Operational modes

Server
•
•
•
•

Apache
Compilation at startup
FastCGI – soon
RepoAuthoritative mode

Vadim Borodavko
Configuration features

config.hdf
•
•
•
•
•
•

Eval
Log
Server
VirtualHost

AdminServer

•
•
•
•
•

Stats
MySQL
Http
Mail...
Configuration features

Eval
Eval {
Jit = true
JitWarmupRequests = 11
JitASize = 536870912
JitAStubsSize = 536870912
JitGl...
Configuration features

Server
Server {
Host = domain.tld
IP = 127.0.0.1
Port = 4247
ThreadCount = 10
SourceRoot = /var/ww...
Configuration features

Server startup options
Server {
DefaultDocument = index.php
StartupDocument = filename
WarmupDocum...
Configuration features

Server http settings
Server {
...
GzipCompressionLevel = 3
EnableMagicQuotesGpc = false
EnableKeep...
Configuration features

VirtualHost
VirtualHost {
default {
Disabled = false
Prefix = prefix.
Pattern = .*
PathTranslation...
Configuration features

VirtualHost  RewriteRules
frontend {
pattern = ^(.*)$
to = app.php/$1
qsa = true
conditions {
not_...
Configuration features

AdminServer, StaticFile
AdminServer {
Port = 4248
ThreadCount = 1
Password = password
}
StaticFile...
Configuration features

Stats, MySQL

Stats {
Web = false
Memory = false
APC = false
APCKey = false
SQL = false
}
MySQL {
...
Configuration features

Http, Mail, Tiers

Http {
DefaultTimeout = 30
SlowQueryThreshold = 5000
}
Mail {
SendmailPath = se...
Configuration features

Vadim Borodavko
Performance: HHVM vs PHP

1.4
Time, ms

Memory, KB

URL
PHP 5.3 PHP 5.5 HHVM 2.2 PHP 5.3 PHP 5.5 HHVM 2.2
/

58

49

17

1...
Performance: HHVM vs PHP

1.4
HHVM 2.2
PHP 5.5
PHP 5.3

Time, ms

0

10

20

30

40

50

60

HHVM 2.2
PHP 5.5
PHP 5.3

Mem...
Performance: HHVM vs PHP

2.3
Time, ms

Memory, KB

URL
PHP 5.3 PHP 5.5

HHVM 2.2

PHP 5.3 PHP 5.5 HHVM 2.2

/

119

91

6...
Performance: HHVM vs PHP

2.3
HHVM 2.2
PHP 5.5
PHP 5.3

Time, ms

0

50

100

150

HHVM 2.2
PHP 5.5
PHP 5.3

Memory, MB

0...
HHVM with your project

Vagrant
$ git clone https://github.com/javer/hhvm-vagrant-vm

$ cd hhvm-vagrant-vm
$ cp -R /var/ww...
HHVM with your project

1.4
•

Symfony
https://github.com/javer/symfony1

• sfPropelORMPlugin
https://github.com/propelorm...
HHVM with your project

2.3

•
•
•
•

Doctrine DBAL
Doctrine 2 ORM

Twig
ResourceBundle

Vadim Borodavko
HHVM with your project

Doctrine DBAL
•

2.3

func_get_args
https://github.com/doctrine/dbal/pull/372

•

implement declar...
HHVM with your project

Doctrine 2 ORM
•

2.3

func_get_args
https://github.com/doctrine/doctrine2/pull/790

•

Preserve c...
HHVM with your project

Twig
•

2.3

Array sometimes can be Traversable
https://github.com/fabpot/Twig/pull/1192

Vadim Bo...
HHVM with your project

2.3
• ResourceBundle
https://github.com/javer/hhvm/tree/intlresourcebundle/hphp/system/php/intl

V...
Popular frameworks and CMS support

HHVM 2.2-dev
Framework

% Unit Tests
Pass

% Unit Tests
Failing

Symfony 2
Doctrine DB...
Popular frameworks and CMS support

HHVM 2.1
Framework

% Unit Tests Pass

% Unit Tests Failing

PHPUnit
Composer
Symfony
...
Competitors

Vadim Borodavko
Competitors

kPHP
•
•
•

Translator PHP into C++
Strict typing

Vkontakte size – 300 MB

Vadim Borodavko
Competitors

kPHP
does not
support OOP

at all.
© 2013
Vadim Borodavko
About me

Vadim Borodavko
• Chief Software Developer at Argentum IT Lab
• E-mail: vadim.borodavko@gmail.com
• GitHub: http...
Upcoming SlideShare
Loading in...5
×

HipHop VM: overclocking Symfony

6,760

Published on

- HipHop – replacement for Zend PHP
- HPHPc and HHVM
- Supported OS
- Compatibility with PHP: version, extensions
- Operational modes: CLI, Server
- Configuration features
- Performance: capital.ua on Symfony 1.4, Sylius on Symfony 2.3
- HHVM with your project: Vagrant
- Popular frameworks and CMS support
- Competitors: kPHP

Published in: Technology
1 Comment
13 Likes
Statistics
Notes
No Downloads
Views
Total Views
6,760
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
30
Comments
1
Likes
13
Embeds 0
No embeds

No notes for slide

HipHop VM: overclocking Symfony

  1. 1. HipHop VM: overclocking Symfony Vadim Borodavko vadim.borodavko@gmail.com
  2. 2. HipHop – replacement for Zend PHP © 2008 – 2013 Vadim Borodavko
  3. 3. 01.10.2013 01.08.2013 01.06.2013 01.04.2013 01.02.2013 01.12.2012 01.10.2012 01.08.2012 01.06.2012 01.04.2012 01.02.2012 01.12.2011 01.10.2011 01.08.2011 01.06.2011 01.04.2011 01.02.2011 01.12.2010 01.10.2010 01.08.2010 01.06.2010 01.04.2010 01.02.2010 HipHop – replacement for Zend PHP Contributors 90 80 70 60 50 40 30 20 10 0 Vadim Borodavko
  4. 4. Two ways HPHPc • • Up to 6x faster than Zend PHP 5.2 No source code in production Vadim Borodavko
  5. 5. Two ways HPHPc • • • Compilation takes long time Big executable files Dynamic code Vadim Borodavko
  6. 6. Two ways HHVM • • • JIT-compilation Dynamic code Edit – Save – Run Vadim Borodavko
  7. 7. Two ways HHVM • The need for revision of the existing PHP-code Vadim Borodavko
  8. 8. Supported OS Mint Ubuntu CentOS Mac OS Debian Arch Fedora Gentoo FreeBSD Vadim Borodavko
  9. 9. Supported OS https://github.com/javer/gentoo-overlay Vadim Borodavko
  10. 10. Compatibility with PHP 5.4.999-hiphop PHP 5.5 – to the end of 2013 year Vadim Borodavko
  11. 11. Compatibility with PHP 5.3 features • • • • • namespaces late static binding goto Closures ternary operator Vadim Borodavko
  12. 12. Compatibility with PHP 5.4 features • • • • • traits $a = [1, 2, 3, 4]; foo()[0] Closures with $this (new Foo)->bar() • Class::{expr}() Vadim Borodavko
  13. 13. Compatibility with PHP 5.5 features • • • • • generators finally* list() in foreach empty(expr) [1, 2, 3][0] • • • password_hash() ClassName::class “Hello”[0] Vadim Borodavko
  14. 14. Compatibility with PHP Extensions 50+ • • • • • • fileinfo imagick intl* mysqli tidy xsl Vadim Borodavko
  15. 15. PHP language extension <?hh class Walk<T as Iterator> { private T $iterator; public function setIterator(T $iterator, int $count): int { $this->iterator = $iterator; $keys = Vector<int> {}; $values = Map<int, string> {}; foreach ($iterator as $k => $v) { $keys->add($k); $values[$k] = $v; } return count($keys); } } $iter = new ArrayIterator([1 => 'first', 2 => 'second']); echo (new Walk<ArrayIterator>)->setIterator($iter,count($iter)); Vadim Borodavko
  16. 16. PHP language extension Vadim Borodavko
  17. 17. PHP language extension Type hinting private int $count; protected string $name; public function setCount(int $count): int { $this->iterator = $iterator; } Vadim Borodavko
  18. 18. PHP language extension Tuples public $t = tuple(“Symfony”, true); Vadim Borodavko
  19. 19. PHP language extension Collections $keys = Vector<int> {}; $values = Map<int, string> {}; $keys->add($k); $values[$k] = $v; echo count($keys); Vadim Borodavko
  20. 20. PHP language extension Generics, Constraints class Walk<T as Iterator> { private T $iter; public function setIterator(T $iter) { ... } } new Walk<ArrayIterator>(); Vadim Borodavko
  21. 21. Operational modes CLI • • • PHP CLI: hhvm --php A bit slower than Zend PHP JIT-compilation* Vadim Borodavko
  22. 22. Operational modes Server • • • • Apache Compilation at startup FastCGI – soon RepoAuthoritative mode Vadim Borodavko
  23. 23. Configuration features config.hdf • • • • • • Eval Log Server VirtualHost AdminServer • • • • • Stats MySQL Http Mail Tiers StaticFile Vadim Borodavko
  24. 24. Configuration features Eval Eval { Jit = true JitWarmupRequests = 11 JitASize = 536870912 JitAStubsSize = 536870912 JitGlobalDataSize = 134217728 } Eval { JitASize = 134217728 JitAStubsSize = 134217728 JitGlobalDataSize = 67108864 } # 512MB # 512MB # 128MB # 128MB # 128MB # 64MB Vadim Borodavko
  25. 25. Configuration features Server Server { Host = domain.tld IP = 127.0.0.1 Port = 4247 ThreadCount = 10 SourceRoot = /var/www/domain.tld IncludeSearchPaths { symfony = /var/www/symfony-1.4 } RequestTimeoutSeconds = 30 RequestMemoryMaxBytes = 134217728 } Vadim Borodavko
  26. 26. Configuration features Server startup options Server { DefaultDocument = index.php StartupDocument = filename WarmupDocument = filename RequestInitFunction = function_name ThreadDocuments { * = somedoc.php * = another.php } ErrorDocument404 = 404.php FatalErrorMessage = Something wrong } Vadim Borodavko
  27. 27. Configuration features Server http settings Server { ... GzipCompressionLevel = 3 EnableMagicQuotesGpc = false EnableKeepAlive = true EnableEarlyFlush = true ForceChunkedEncoding = false MaxPostSize = 65 # in MB LibEventSyncSend = true ResponseQueueCount = 0 ... } Vadim Borodavko
  28. 28. Configuration features VirtualHost VirtualHost { default { Disabled = false Prefix = prefix. Pattern = .* PathTranslation = web/ ServerName = domain.tld ServerVariables { name = value } RewriteRules { } } } Vadim Borodavko
  29. 29. Configuration features VirtualHost RewriteRules frontend { pattern = ^(.*)$ to = app.php/$1 qsa = true conditions { not_script { pattern = .php$ type = request negate = true } } } Vadim Borodavko
  30. 30. Configuration features AdminServer, StaticFile AdminServer { Port = 4248 ThreadCount = 1 Password = password } StaticFile { Extensions { bmp = image/bmp } Generators { * = static_resource.php } } Vadim Borodavko
  31. 31. Configuration features Stats, MySQL Stats { Web = false Memory = false APC = false APCKey = false SQL = false } MySQL { ReadOnly = false ConnectTimeout = 1000 ReadTimeout = 4000 SlowQueryThreshold = 2000 KillOnTimeout = false } Vadim Borodavko
  32. 32. Configuration features Http, Mail, Tiers Http { DefaultTimeout = 30 SlowQueryThreshold = 5000 } Mail { SendmailPath = sendmail -t -i ForceExtraParameters = } Tiers { * { machine = /regex pattern/ overwrite { ... } } } Vadim Borodavko
  33. 33. Configuration features Vadim Borodavko
  34. 34. Performance: HHVM vs PHP 1.4 Time, ms Memory, KB URL PHP 5.3 PHP 5.5 HHVM 2.2 PHP 5.3 PHP 5.5 HHVM 2.2 / 58 49 17 18 668 16 128 615 /politics 57 48 16 18 688 15 872 598 /publication/5 129- 68 54 18 23 808 20 736 607 /publication 56 45 17 18 176 15 360 606 /issue/92 51 40 15 17 408 14 592 617 /app 45 36 13 16 128 13 824 498 /time 56 45 16 18 432 15 616 554 /tag/siriya 61 49 18 18 784 16 032 586 Vadim Borodavko
  35. 35. Performance: HHVM vs PHP 1.4 HHVM 2.2 PHP 5.5 PHP 5.3 Time, ms 0 10 20 30 40 50 60 HHVM 2.2 PHP 5.5 PHP 5.3 Memory, MB 0 5 10 15 20 Vadim Borodavko
  36. 36. Performance: HHVM vs PHP 2.3 Time, ms Memory, KB URL PHP 5.3 PHP 5.5 HHVM 2.2 PHP 5.3 PHP 5.5 HHVM 2.2 / 119 91 67 13 056 10 240 796 /t/t-shirts 139 105 74 15 360 12 032 1 315 /p/t-shirtautem 123 94 68 15 616 11 264 662 /cart 106 81 63 13 056 10 240 550 /register/ 109 84 64 14 336 10 752 571 /login 102 78 61 12 288 9 728 549 Vadim Borodavko
  37. 37. Performance: HHVM vs PHP 2.3 HHVM 2.2 PHP 5.5 PHP 5.3 Time, ms 0 50 100 150 HHVM 2.2 PHP 5.5 PHP 5.3 Memory, MB 0 5 10 15 Vadim Borodavko
  38. 38. HHVM with your project Vagrant $ git clone https://github.com/javer/hhvm-vagrant-vm $ cd hhvm-vagrant-vm $ cp -R /var/www/site/* ./ $ vagrant up $ wget http://127.0.0.1:9080/ $ wget http://127.0.0.1:9081/ Vadim Borodavko
  39. 39. HHVM with your project 1.4 • Symfony https://github.com/javer/symfony1 • sfPropelORMPlugin https://github.com/propelorm/sfPropelORMPlugin • Propel https://github.com/propelorm/Propel • Phing 2.6+ https://github.com/phingofficial/phing Vadim Borodavko
  40. 40. HHVM with your project 2.3 • • • • Doctrine DBAL Doctrine 2 ORM Twig ResourceBundle Vadim Borodavko
  41. 41. HHVM with your project Doctrine DBAL • 2.3 func_get_args https://github.com/doctrine/dbal/pull/372 • implement declared interfaces https://github.com/doctrine/dbal/pull/373 PDOConnection extends PDO implements Connection PDOStatement extends PDOStatement implements Statement Vadim Borodavko
  42. 42. HHVM with your project Doctrine 2 ORM • 2.3 func_get_args https://github.com/doctrine/doctrine2/pull/790 • Preserve class property DocComment for reflection https://github.com/facebook/hhvm/pull/1199 Vadim Borodavko
  43. 43. HHVM with your project Twig • 2.3 Array sometimes can be Traversable https://github.com/fabpot/Twig/pull/1192 Vadim Borodavko
  44. 44. HHVM with your project 2.3 • ResourceBundle https://github.com/javer/hhvm/tree/intlresourcebundle/hphp/system/php/intl Vadim Borodavko
  45. 45. Popular frameworks and CMS support HHVM 2.2-dev Framework % Unit Tests Pass % Unit Tests Failing Symfony 2 Doctrine DBAL Doctrine 2 ORM Twig PHPUnit Composer Symfony 1.4 98.12 97.61 99.41 100 90.52 99.13 97 1.51 1.39 0.59 0 9.48 0.87 3 % Unit Tests Causing HHVM to Fatal 0.37 1.00 0 0 0 0 0 Vadim Borodavko
  46. 46. Popular frameworks and CMS support HHVM 2.1 Framework % Unit Tests Pass % Unit Tests Failing PHPUnit Composer Symfony CakePHP Wordpress Joomla phpBB phpMyAdmin Laravel Zend Framework 2 yii Slim Doctrine Assetic Twig Drupal Paris Idiorm CodeIgniter Magento 90 97 91 0 76 0 0 0 95 0 92 99 0 80 78 98 100 100 81 0 10 3 9 Tests won't run 24 Tests won't run 100 Tests won't run 3 Tests won't run 8 1 Tests won't run 20 22 2 0 0 19 Tests won't run % Unit Tests Causing HHVM to Fatal 0 <1 <1 Tests won't run <1 Tests won't run 0 Tests won't run 2 Tests won't run <1 0 Tests won't run 0 0 0 0 0 <1 Tests won't run Vadim Borodavko
  47. 47. Competitors Vadim Borodavko
  48. 48. Competitors kPHP • • • Translator PHP into C++ Strict typing Vkontakte size – 300 MB Vadim Borodavko
  49. 49. Competitors kPHP does not support OOP at all. © 2013 Vadim Borodavko
  50. 50. About me Vadim Borodavko • Chief Software Developer at Argentum IT Lab • E-mail: vadim.borodavko@gmail.com • GitHub: https://github.com/javer • LinkedIn: http://linkedin.com/in/javer • Twitter: https://twitter.com/mrjaver All trademarks are property of their respective owners Vadim Borodavko
  1. ¿Le ha llamado la atención una diapositiva en particular?

    Recortar diapositivas es una manera útil de recopilar información importante para consultarla más tarde.

×