50
PHP7, hhvm & co Pierre Joye PHP 7, HHVM & CO Pierre Joye

Php 7 hhvm and co

Embed Size (px)

DESCRIPTION

Present new things coming to PHP 7, and the alternative PHP implementations as well as less intrusive solutions to speed up PHP.

Citation preview

Page 1: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

PHP 7, HHVM & CO

Pierre Joye

Page 2: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Pierre Joye@[email protected]://www.slideshare.net/pierrej

PHP Core developerContributors to numerous OSS projects

Portability fan

Page 3: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Stats

Page 4: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

What‘s going in the php world?

https://wiki.php.net/rfc/isset_ternary

Page 5: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

PHP 5.32009 - 2014

Page 6: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

PHP 5.4Security fixes only

Page 7: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

PHP 5.6.0 is out!(btw, 5.6.1 too)

Page 8: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

5 + 1 = 7

Page 9: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Roadmap

Page 10: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Features

• Rewamped Engine• True 64bit support• Large string and LFS (Large file support)• Consistent variables syntax• No more fatal error on calling method on non

object• New ?? operator• Many features under discussions

Page 11: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Recoverable error for non object

Page 12: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Recoverable error for non object

https://wiki.php.net/rfc/catchable-call-to-member-of-non-object

<?php set_error_handler(function($code,$message) { var_dump($code, $message);

});

$x= null; var_dump($x->method());echo "Alive\n";

Page 13: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Null Coalesce Operator (??)

Page 14: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Null Coalesce Operator (??)

<?php$username = $_GET['user'] ?? 'nobody'; $username = isset($_GET['user']) ? $_GET['user'] : 'nobody';

// Method/function call$model = Model::get($id) ?? $default_model;if (($model = Model::get($id)) === NULL) { $model = $default_model; }

// Chained$x = NULL; $y = NULL; $z = 3; var_dump($x ?? $y ?? $z);

https://wiki.php.net/rfc/isset_ternary

Page 15: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

PHP Language Specificationhttps://github.com/php/php-langspec

Page 16: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Open & Public Specifications

Competions++

Page 17: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Page 18: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Page 19: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

(Most) Focus on Speed

Page 20: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Page 21: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

SPEED is NOT SCALE

Page 22: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

SPEED is UX

Page 23: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Scale is Server SideArchitecture (Apps, Ops, Net, …)

Page 24: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

My code sucks.

Page 25: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Yours too.

Page 26: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Steroids++

Page 27: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

So?

Page 28: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Page 29: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Page 30: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

QB<?php class OilPaintFilter {

/** @var int32 */ public $levels = 25;/** @var int32 */ public $filterSize = 5;/** * @engine qb * * @param image $dst * @param image $src * * @local float32[*][r,g,b,a] $bin * @local float32 $max_intensity * @local int32 $(current_index|max_index) * @local int32 $(filter_x|filter_y|filter_offset) * @local int32 $(x|y|x_limit|y_limit) * @local int32 $(width|height) * @local float32[r,g,b,a] $pixel * @local float32 $multiplier */public function filter(&$dst, $src) {…

Page 31: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

QB

<?php function calc($n, &$a) {

$b = 18;while($n) {

$a = $b * $b * $b * $b;$n--;

}}$n = 5000000;$a = 0;calc($n, $a); $end = microtime(true);

Page 32: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

QB

Source: http://php-qb.net/index.php/2-uncategorised/27-comparing-performance-in-qb-with-hhvm

Page 33: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Zephir

Page 34: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Zephir

Optimization & code generation

Compilation + optimization

Native execution

Page 35: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Zephirnamespace MyLibrary; class Filter {public function alpha(string str) {

char ch;string filtered = "";for ch in str {

if (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') {

let filtered .= ch;}

} return filtered; }}

Page 36: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Zephir

<?php $filter = new MyLibrary\Filter();echo $filter>alpha("01he#l.lo?/1");

Page 37: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

PHP Alternative Implementations

Page 38: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

PHP Alternative Implementations

• PHP7 (formely known as phpng)• HHVM (native code)• Recki-ct (native code)• Phalanger (.net engine)

Page 39: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Recki-ct

Page 40: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Recki-CT

PHP Cache

Parser (AST in 7+)

Recki IR

JIT~

Native Code

Page 41: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Recki-ctphp 5.5 Recki-CT hhvm 3.2 hippy-c qb

simple() 139.63357 1.00000 8.30447 7.65693 8.35018

simplecall() 38.99476 FAIL 1.32552 1.00000 FAIL

simpleucall() 54.02041 1.00000 3.52439 1.51072 47.91090

simpleudcall() 52.14534 1.00000 3.75936 1.41614 47.55259

mandel() 21.26249 1.00000 2.03372 2.11208 FAIL

mandel_typed() 23.16553 1.00000 2.11128 2.09212 3.00061

mandel2() 24.43275 1.00000 2.57704 1.87802 FAIL

mandel2_typed() 23.79989 1.00000 2.90105 1.57193 7.11054

Page 42: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Recki-ctphp 5.5 Recki-CT hhvm 3.2 hippy-c qb

ary(50000) 1.39338 FAIL 1.00000 4.47888 FAIL

ary2(50000) 1.26952 FAIL 1.00000 2.28231 FAIL

ary3(2000) 5.96015 FAIL 1.70997 1.00000 FAIL

fibo(30) 39.48440 1.00000 1.60647 16.40883 FAIL

hash1(50000) 1.70014 FAIL 1.00000 3.27314 FAIL

hash2(500) 2.23648 FAIL 1.00000 1.30044 FAIL

heapsort(20000) 3.67800 FAIL 1.00000 4.96699 FAIL

Page 43: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Page 44: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

HHVM

PHP Cache

Parser (AST in 7+)

HHVM Opcodes

Native Code

JIT ~

Cache

Page 45: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Page 46: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

PHP

PHP Cache

Parser (AST in 7+)

OpCodes

Page 47: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Resources

5.5 + opcache : 33.26 [#/sec]

7 (October 2014) + opcache : 41.61 [#/sec]

Hhvm (October 2014) : 57.74 [#/sec]

Page 50: Php 7 hhvm and co

PHP7, hhvm & coPierre Joye

Resources

• http://phpdbg.com/• http://windows.php.net/qa/• http://qa.php.net/