SlideShare ist ein Scribd-Unternehmen logo
1 von 61
PHP 7, HHVM & CO
#PHPKonf
Istanbul
Pierre Joye
PHP7, hhvm & co
Pierre Joye
@pierrejoye
pierre@php.net
http://www.slideshare.net/pierrej
PHP Core developer
Contributors to numerous OSS projects
Portability fan
PHP7, hhvm & co
Stats
PHP7, hhvm & co
Awesome new extension installer
https://github.com/FriendsOfPHP/pickle
PHP7, hhvm & co
What‘s going in the php world?
https://wiki.php.net/rfc/isset_ternary
PHP7, hhvm & co
PHP 5.3
2009 - 2014
PHP7, hhvm & co
PHP 5.4 and 5.5
Security fixes only
PHP7, hhvm & co
PHP 5.4
2012 - 2015
PHP7, hhvm & co
PHP 5.5
2013 - 2016
PHP7, hhvm & co
PHP 5.6.11 is out!
PHP7, hhvm & co
5 + 1 = 7
PHP7, hhvm & co
6.6.6
PHP7, hhvm & co
PHP 7.0.0beta2 yesterday!
PHP7, hhvm & co
PHP 7.0 – Future is now
PHP7, hhvm & co
PHP 7.0 – speed++
PHP7, hhvm & co
LIES, DAMN LIES AND BENCHMARKS
PHP7, hhvm & co
PHP7, hhvm & co
PHP7, hhvm & co
Features
• Rewamped Engine
• True 64bit support
• Large string and LFS (Large file support)
• Consistent variables syntax
• Error exception instead of fatal error
• Scalar type declarations
• Zero cost asserts
PHP7, hhvm & co
Features
• Secure RNG
• PHP4 constructors deprecated
• JIT enabled PCRE
• Removed ext/mysql, ext/ereg and more
• New ?? Operator
• New JSON parser
• Many other features, a lot already target 7.1
PHP7, hhvm & co
Error exception instead of fatal error
PHP7, hhvm & co
Error exception
https://wiki.php.net/rfc/catchable-call-to-member-of-non-object
<?php
try {
$x = null;
var_dump($x->method());
// The exception class name is EngineException
// in alpha1
} catch (Error $e) {
// pass
}
echo "Aliven";
PHP7, hhvm & co
Scalar Type Declarations
PHP7, hhvm & co
Scalar Type Declarations
<?php
declare(strict_types = 1);
function add(int $a, int $b) : int {
return $a + $b;
}
$x = add(1, 2);
// The exception class name TypeException
// in alpha1
$y = add(0.1, 0.2); // TypeError exception
https://wiki.php.net/rfc/scalar_type_hints_v5
PHP7, hhvm & co
Null Coalesce Operator (??)
PHP7, hhvm & co
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
PHP7, hhvm & co
PHP Language Specification
https://github.com/php/php-langspec
PHP7, hhvm & co
Open & Public Specifications
Competions++
PHP7, hhvm & co
PHP7, hhvm & co
PHP7, hhvm & co
(Most) Focus on Speed
PHP7, hhvm & co
PHP7, hhvm & co
SPEED is NOT SCALE
PHP7, hhvm & co
SPEED is UX
PHP7, hhvm & co
Scale is Server Side
Architecture (Apps, Ops, Net, …)
PHP7, hhvm & co
My code sucks.
PHP7, hhvm & co
Yours too.
PHP7, hhvm & co
Steroids++
PHP7, hhvm & co
So?
PHP7, hhvm & co
PHP7, hhvm & co
PHP7, hhvm & co
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) {…
PHP7, hhvm & co
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);
PHP7, hhvm & co
QB
Source: http://php-qb.net/index.php/2-uncategorised/27-comparing-performance-in-qb-with-hhvm
See http://benchmarksgame.alioth.debian.org/u32/performance.php?test=spectralnorm or other
PHP7, hhvm & co
Zephir
PHP7, hhvm & co
Zephir
Optimization & code generation
Compilation + optimization
Native execution
PHP7, hhvm & co
Zephir
namespace 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;
}
}
PHP7, hhvm & co
Zephir
<?php
$filter = new MyLibraryFilter();
echo $filter>alpha("01he#l.lo?/1");
PHP7, hhvm & co
PHP Alternative Implementations
PHP7, hhvm & co
PHP Alternative Implementations
• HHVM (native code)
• Recki-ct (native code)
• Phalanger (.net engine)
PHP7, hhvm & co
PHP7, hhvm & co
HHVM
PHP Cache
Parser (AST in 7+)
HHVM Opcodes
Native Code
JIT ~
Cache
PHP7, hhvm & co
PHP7, hhvm & co
PHP
PHP Cache
Parser (AST in 7+)
OpCodes
PHP7, hhvm & co
Recki-ct
PHP7, hhvm & co
Recki-CT
PHP Cache
Parser (AST in 7+)
Recki IR
JIT~
Native Code
PHP7, hhvm & co
Recki-ct
php 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_typ
ed()
23.16553 1.00000 2.11128 2.09212 3.00061
mandel2() 24.43275 1.00000 2.57704 1.87802 FAIL
mandel2_ty
ped()
23.79989 1.00000 2.90105 1.57193 7.11054
PHP7, hhvm & co
Recki-ct
php 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(2000
0)
3.67800 FAIL 1.00000 4.96699 FAIL
PHP7, hhvm & co
Resources
• http://wiki.php.net/rfc/
• http://zephir-lang.com/
• http://www.slideshare.net/ircmaxell/high-
performance-php-phpnw
• http://talks.php.net/fluent15#/
• https://github.com/google/recki-ct
• http://blog.ircmaxell.com/2014/08/introducing-
recki-ct.html
• https://github.com/chung-
leong/qb/wiki/Introduction
PHP7, hhvm & co
Resources
• https://edit.php.net/
• https://wiki.php.net/rfc/phpng
• https://wiki.php.net/rfc/abstract_syntax_tree
• http://hhvm.com/blog/6323/the-journey-of-a-
thousand-bytecodes
• https://github.com/php/php-
src/blob/master/UPGRADING
• https://github.com/php/php-
src/blob/master/UPGRADING.INTERNALS
PHP7, hhvm & co
Resources
• http://phpdbg.com/
• http://windows.php.net/qa/
• http://qa.php.net/
• http://ongr.io
• http://aka.ms/AzureCodeManiac2015

Weitere ähnliche Inhalte

Was ist angesagt?

How to deploy node to production
How to deploy node to productionHow to deploy node to production
How to deploy node to production
Sean Hess
 
Socket programming with php
Socket programming with phpSocket programming with php
Socket programming with php
Elizabeth Smith
 
Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門
lestrrat
 

Was ist angesagt? (20)

Key features PHP 5.3 - 5.6
Key features PHP 5.3 - 5.6Key features PHP 5.3 - 5.6
Key features PHP 5.3 - 5.6
 
The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5
 
Php in 2013 (Web-5 2013 conference)
Php in 2013 (Web-5 2013 conference)Php in 2013 (Web-5 2013 conference)
Php in 2013 (Web-5 2013 conference)
 
Php internal architecture
Php internal architecturePhp internal architecture
Php internal architecture
 
How to inspect a RUNNING perl process
How to inspect a RUNNING perl processHow to inspect a RUNNING perl process
How to inspect a RUNNING perl process
 
Php7 HHVM and co
Php7 HHVM and coPhp7 HHVM and co
Php7 HHVM and co
 
Modern Perl for the Unfrozen Paleolithic Perl Programmer
Modern Perl for the Unfrozen Paleolithic  Perl ProgrammerModern Perl for the Unfrozen Paleolithic  Perl Programmer
Modern Perl for the Unfrozen Paleolithic Perl Programmer
 
The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6
 
How to deploy node to production
How to deploy node to productionHow to deploy node to production
How to deploy node to production
 
Hacking with hhvm
Hacking with hhvmHacking with hhvm
Hacking with hhvm
 
Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011
 
PSGI and Plack from first principles
PSGI and Plack from first principlesPSGI and Plack from first principles
PSGI and Plack from first principles
 
Zend con 2016 - Asynchronous Prorgamming in PHP
Zend con 2016 - Asynchronous Prorgamming in PHPZend con 2016 - Asynchronous Prorgamming in PHP
Zend con 2016 - Asynchronous Prorgamming in PHP
 
Preparing code for Php 7 workshop
Preparing code for Php 7 workshopPreparing code for Php 7 workshop
Preparing code for Php 7 workshop
 
Socket programming with php
Socket programming with phpSocket programming with php
Socket programming with php
 
Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門Kansai.pm 10周年記念 Plack/PSGI 入門
Kansai.pm 10周年記念 Plack/PSGI 入門
 
Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)
Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)
Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)
 
The why and how of moving to php 5.4/5.5
The why and how of moving to php 5.4/5.5The why and how of moving to php 5.4/5.5
The why and how of moving to php 5.4/5.5
 
Zephir - A Wind of Change for writing PHP extensions
Zephir - A Wind of Change for writing PHP extensionsZephir - A Wind of Change for writing PHP extensions
Zephir - A Wind of Change for writing PHP extensions
 
Pycon - Python for ethical hackers
Pycon - Python for ethical hackers Pycon - Python for ethical hackers
Pycon - Python for ethical hackers
 

Ähnlich wie Php7 hhvm and co

GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHP
Nat Weerawan
 
Php i basic chapter 3
Php i basic chapter 3Php i basic chapter 3
Php i basic chapter 3
Muhamad Al Imran
 
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Muhamad Al Imran
 
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Muhamad Al Imran
 

Ähnlich wie Php7 hhvm and co (20)

What To Expect From PHP7
What To Expect From PHP7What To Expect From PHP7
What To Expect From PHP7
 
[4developers2016] PHP 7 (Michał Pipa)
[4developers2016] PHP 7 (Michał Pipa)[4developers2016] PHP 7 (Michał Pipa)
[4developers2016] PHP 7 (Michał Pipa)
 
What's new with PHP7
What's new with PHP7What's new with PHP7
What's new with PHP7
 
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
 
The new features of PHP 7
The new features of PHP 7The new features of PHP 7
The new features of PHP 7
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHP
 
Giới thiệu PHP 7
Giới thiệu PHP 7Giới thiệu PHP 7
Giới thiệu PHP 7
 
Introduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHPIntroduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHP
 
Php mysql training-in-mumbai
Php mysql training-in-mumbaiPhp mysql training-in-mumbai
Php mysql training-in-mumbai
 
Php 7 compliance workshop singapore
Php 7 compliance workshop singaporePhp 7 compliance workshop singapore
Php 7 compliance workshop singapore
 
Wt unit 4 server side technology-2
Wt unit 4 server side technology-2Wt unit 4 server side technology-2
Wt unit 4 server side technology-2
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
CodePolitan Webinar: The Rise of PHP
CodePolitan Webinar: The Rise of PHPCodePolitan Webinar: The Rise of PHP
CodePolitan Webinar: The Rise of PHP
 
PHP: The easiest language to learn.
PHP: The easiest language to learn.PHP: The easiest language to learn.
PHP: The easiest language to learn.
 
Peek at PHP 7
Peek at PHP 7Peek at PHP 7
Peek at PHP 7
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
Php i basic chapter 3
Php i basic chapter 3Php i basic chapter 3
Php i basic chapter 3
 
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
 
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
 

Mehr von Pierre Joye

Webdevcon Keynote hh-2012-09-18
Webdevcon Keynote hh-2012-09-18Webdevcon Keynote hh-2012-09-18
Webdevcon Keynote hh-2012-09-18
Pierre Joye
 
Intro ipcberlin2012
Intro ipcberlin2012Intro ipcberlin2012
Intro ipcberlin2012
Pierre Joye
 
Php symfony and software lifecycle
Php symfony and software lifecyclePhp symfony and software lifecycle
Php symfony and software lifecycle
Pierre Joye
 

Mehr von Pierre Joye (17)

Php 7.x 8.0 and hhvm and
Php 7.x 8.0 and hhvm and Php 7.x 8.0 and hhvm and
Php 7.x 8.0 and hhvm and
 
Extending php (7), the basics
Extending php (7), the basicsExtending php (7), the basics
Extending php (7), the basics
 
Php core. get rid of bugs and contribute
Php core. get rid of bugs and contributePhp core. get rid of bugs and contribute
Php core. get rid of bugs and contribute
 
Webdevcon Keynote hh-2012-09-18
Webdevcon Keynote hh-2012-09-18Webdevcon Keynote hh-2012-09-18
Webdevcon Keynote hh-2012-09-18
 
Devcon hh-2012
Devcon hh-2012Devcon hh-2012
Devcon hh-2012
 
Short Intro talk to IPC/Berlin 2012
Short Intro talk to IPC/Berlin 2012Short Intro talk to IPC/Berlin 2012
Short Intro talk to IPC/Berlin 2012
 
Intro ipcberlin2012
Intro ipcberlin2012Intro ipcberlin2012
Intro ipcberlin2012
 
Webdevcon pierrejoye-php54-and-other
Webdevcon pierrejoye-php54-and-otherWebdevcon pierrejoye-php54-and-other
Webdevcon pierrejoye-php54-and-other
 
Php symfony and software lifecycle
Php symfony and software lifecyclePhp symfony and software lifecycle
Php symfony and software lifecycle
 
Mongodb - drupal dev days
Mongodb - drupal dev daysMongodb - drupal dev days
Mongodb - drupal dev days
 
Webplatform And Php
Webplatform And PhpWebplatform And Php
Webplatform And Php
 
Keynote, PHP World Kongress Munich
Keynote, PHP World Kongress MunichKeynote, PHP World Kongress Munich
Keynote, PHP World Kongress Munich
 
Php On Windows
Php On WindowsPhp On Windows
Php On Windows
 
Php On Windows Internals
Php On Windows InternalsPhp On Windows Internals
Php On Windows Internals
 
Test Fest 2009
Test Fest 2009Test Fest 2009
Test Fest 2009
 
PHP Worl Kongress Munich
PHP Worl Kongress MunichPHP Worl Kongress Munich
PHP Worl Kongress Munich
 
Developing PHP internals on Windows
Developing PHP internals on WindowsDeveloping PHP internals on Windows
Developing PHP internals on Windows
 

KĂźrzlich hochgeladen

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

KĂźrzlich hochgeladen (20)

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

Php7 hhvm and co

  • 1. PHP 7, HHVM & CO #PHPKonf Istanbul Pierre Joye
  • 2. PHP7, hhvm & co Pierre Joye @pierrejoye pierre@php.net http://www.slideshare.net/pierrej PHP Core developer Contributors to numerous OSS projects Portability fan
  • 3. PHP7, hhvm & co Stats
  • 4. PHP7, hhvm & co Awesome new extension installer https://github.com/FriendsOfPHP/pickle
  • 5. PHP7, hhvm & co What‘s going in the php world? https://wiki.php.net/rfc/isset_ternary
  • 6. PHP7, hhvm & co PHP 5.3 2009 - 2014
  • 7. PHP7, hhvm & co PHP 5.4 and 5.5 Security fixes only
  • 8. PHP7, hhvm & co PHP 5.4 2012 - 2015
  • 9. PHP7, hhvm & co PHP 5.5 2013 - 2016
  • 10. PHP7, hhvm & co PHP 5.6.11 is out!
  • 11. PHP7, hhvm & co 5 + 1 = 7
  • 12. PHP7, hhvm & co 6.6.6
  • 13. PHP7, hhvm & co PHP 7.0.0beta2 yesterday!
  • 14. PHP7, hhvm & co PHP 7.0 – Future is now
  • 15. PHP7, hhvm & co PHP 7.0 – speed++
  • 16. PHP7, hhvm & co LIES, DAMN LIES AND BENCHMARKS
  • 19. PHP7, hhvm & co Features • Rewamped Engine • True 64bit support • Large string and LFS (Large file support) • Consistent variables syntax • Error exception instead of fatal error • Scalar type declarations • Zero cost asserts
  • 20. PHP7, hhvm & co Features • Secure RNG • PHP4 constructors deprecated • JIT enabled PCRE • Removed ext/mysql, ext/ereg and more • New ?? Operator • New JSON parser • Many other features, a lot already target 7.1
  • 21. PHP7, hhvm & co Error exception instead of fatal error
  • 22. PHP7, hhvm & co Error exception https://wiki.php.net/rfc/catchable-call-to-member-of-non-object <?php try { $x = null; var_dump($x->method()); // The exception class name is EngineException // in alpha1 } catch (Error $e) { // pass } echo "Aliven";
  • 23. PHP7, hhvm & co Scalar Type Declarations
  • 24. PHP7, hhvm & co Scalar Type Declarations <?php declare(strict_types = 1); function add(int $a, int $b) : int { return $a + $b; } $x = add(1, 2); // The exception class name TypeException // in alpha1 $y = add(0.1, 0.2); // TypeError exception https://wiki.php.net/rfc/scalar_type_hints_v5
  • 25. PHP7, hhvm & co Null Coalesce Operator (??)
  • 26. PHP7, hhvm & co 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
  • 27. PHP7, hhvm & co PHP Language Specification https://github.com/php/php-langspec
  • 28. PHP7, hhvm & co Open & Public Specifications Competions++
  • 31. PHP7, hhvm & co (Most) Focus on Speed
  • 33. PHP7, hhvm & co SPEED is NOT SCALE
  • 34. PHP7, hhvm & co SPEED is UX
  • 35. PHP7, hhvm & co Scale is Server Side Architecture (Apps, Ops, Net, …)
  • 36. PHP7, hhvm & co My code sucks.
  • 37. PHP7, hhvm & co Yours too.
  • 38. PHP7, hhvm & co Steroids++
  • 39. PHP7, hhvm & co So?
  • 42. PHP7, hhvm & co 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) {…
  • 43. PHP7, hhvm & co 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);
  • 44. PHP7, hhvm & co QB Source: http://php-qb.net/index.php/2-uncategorised/27-comparing-performance-in-qb-with-hhvm See http://benchmarksgame.alioth.debian.org/u32/performance.php?test=spectralnorm or other
  • 45. PHP7, hhvm & co Zephir
  • 46. PHP7, hhvm & co Zephir Optimization & code generation Compilation + optimization Native execution
  • 47. PHP7, hhvm & co Zephir namespace 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; } }
  • 48. PHP7, hhvm & co Zephir <?php $filter = new MyLibraryFilter(); echo $filter>alpha("01he#l.lo?/1");
  • 49. PHP7, hhvm & co PHP Alternative Implementations
  • 50. PHP7, hhvm & co PHP Alternative Implementations • HHVM (native code) • Recki-ct (native code) • Phalanger (.net engine)
  • 52. PHP7, hhvm & co HHVM PHP Cache Parser (AST in 7+) HHVM Opcodes Native Code JIT ~ Cache
  • 54. PHP7, hhvm & co PHP PHP Cache Parser (AST in 7+) OpCodes
  • 55. PHP7, hhvm & co Recki-ct
  • 56. PHP7, hhvm & co Recki-CT PHP Cache Parser (AST in 7+) Recki IR JIT~ Native Code
  • 57. PHP7, hhvm & co Recki-ct php 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_typ ed() 23.16553 1.00000 2.11128 2.09212 3.00061 mandel2() 24.43275 1.00000 2.57704 1.87802 FAIL mandel2_ty ped() 23.79989 1.00000 2.90105 1.57193 7.11054
  • 58. PHP7, hhvm & co Recki-ct php 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(2000 0) 3.67800 FAIL 1.00000 4.96699 FAIL
  • 59. PHP7, hhvm & co Resources • http://wiki.php.net/rfc/ • http://zephir-lang.com/ • http://www.slideshare.net/ircmaxell/high- performance-php-phpnw • http://talks.php.net/fluent15#/ • https://github.com/google/recki-ct • http://blog.ircmaxell.com/2014/08/introducing- recki-ct.html • https://github.com/chung- leong/qb/wiki/Introduction
  • 60. PHP7, hhvm & co Resources • https://edit.php.net/ • https://wiki.php.net/rfc/phpng • https://wiki.php.net/rfc/abstract_syntax_tree • http://hhvm.com/blog/6323/the-journey-of-a- thousand-bytecodes • https://github.com/php/php- src/blob/master/UPGRADING • https://github.com/php/php- src/blob/master/UPGRADING.INTERNALS
  • 61. PHP7, hhvm & co Resources • http://phpdbg.com/ • http://windows.php.net/qa/ • http://qa.php.net/ • http://ongr.io • http://aka.ms/AzureCodeManiac2015

Hinweis der Redaktion

  1. Optimum value engineering
  2. September 2015
  3. Pomato pap, tomato mom and a small tomato are crossing the road. The tomato pap tells the small tomato – hurry up, catchup. – secret files, not by word citation 
  4. Fall 2015 Stabilization RFCs in discussions More optimizatons coming
  5. Fall 2015 Stabilization RFCs in discussions More optimizatons coming
  6. Scalar types – Andrea Faulds, Anthony Ferrara … CSPRNG – Sammy Kaye Powers
  7. Fall 2015 Stabilization RFCs in discussions More optimizatons coming
  8. Fall 2015 Stabilization RFCs in discussions More optimizatons coming
  9. Fall 2015 Stabilization RFCs in discussions More optimizatons coming
  10. Yes but…. Speed is not scale Most of you have no scaling problem Your code simply sucks (mines too) Changing languages, servers, platforms do not fix scale issues Fix your code, design and architecture Fast PHP is about scale, not speed.
  11. Except Lars‘
  12. Except Lars‘
  13. Function calls poorly implemented
  14. Delivery Man: Morning, Sir, I've got a parrot for Mr "Poy-rot". Hercule Poirot: No no no! Poirot. It is pronounced "Pwa-roe". Delivery Man: I beg your pardon, Governor. I've got a "pwa-roe" for Mr "Poy-rot".