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

The PHP7 Story - Zeev Suraski

The PHP7 Story - Zeev Suraski

לאחר יותר מעשור ללא גרסה מאג'ורית של PHP – גרסה 7 מהווה אבן דרך משמעותית ומלהיבה בהסטוריה של השפה. PHP 7 מבטיחה להביא שיפורי ביצועים מרחיקי דרך בשילוב מגוון של יכולות חדשות. בהרצאה זו, זאב יתאר את האבולוציה של הגרסאות המרכזיות של PHP, את סיפור "מאחורי הקלעים" של הולדתה של PHP 7 ואת היכולות המרכזיות החדשות של השפה.

WordCamp Israel

March 28, 2016
Tweet

More Decks by WordCamp Israel

Other Decks in Programming

Transcript

  1. Zeev Suraski

    WordCamp Israel 2016

    View Slide

  2. • 3 daughters
    • Photography enthusiast
    • Crazy about spicy foods
    • CS graduate at the Technion, Israel Institute of Technology
    • Early technological career – GW-BASIC apps, C++ CGIs, C&C army systems
    • Co-architect of PHP, Co-founder & CTO of Zend
    About Me

    View Slide

  3. How I got involved

    View Slide

  4. A Humble Beginning
    4

    View Slide

  5. PHP’s popular. Really.

    View Slide

  6. EVOLUTION

    View Slide

  7. PHP 3.0
    ● Released: June 1998
    ● New Features:
    ● Full fledged language
    ● Extensions

    View Slide

  8. PHP 4.0
    ● Released: May 2000
    ● New Features:
    ● Zend Engine
    ● Modularity
    ● Sessions
    ● Downwards compatibility (!)
    ● Language plugins

    View Slide

  9. PHP 5
    ● 5.0: July 2004
    ● New Features:
    ● New “true“ object model
    ● Destructors
    ● Exception handling
    ● Not Slower
    ● Seeds were sown...

    View Slide

  10. PHP Performance Evolution

    bench.php (lower is better)
    0 3.5 7 10.5 14
    12.682
    12.537
    4.679
    4.201
    2.911
    2.177
    2.031
    1.92
    5.6 (Aug 2014)
    5.5 (Jun 2013)
    5.4 (Mar 2012)
    5.3 (Nov 2009)
    5.2 (Nov 2006)
    5.1 (Nov 2005)
    5.0 (Jul 2004)
    4.4 (Jul 2005)

    View Slide

  11. Putting Things in Perspective
    0 20 40 60 80
    75
    12.682
    12.537
    4.679
    4.201
    2.911
    2.177
    2.031
    1.92
    5.6 (Aug 2014)
    5.5 (Jun 2013)
    5.4 (Mar 2012)
    5.3 (Nov 2009)
    5.2 (Nov 2006)
    5.1 (Nov 2005)
    5.0 (Jul 2004)
    4.4 (Jul 2005)
    3.0 (Jun 1998)

    View Slide

  12. PHP 6

    View Slide

  13. The Premise

    View Slide

  14. Full Language-Level Unicode

    View Slide

  15. What Ended Up Happening
    phpBB
    phpMyAdmin
    WordPress
    0 55 110 165 220
    101.3
    182.4
    206.1
    72.8
    134
    113.6
    PHP 6.0
    PHP 5.3
    Bonus: Roughly doubled memory footprint.

    View Slide

  16. The End
    http://bit.ly/php6whathappened

    View Slide

  17. PHP 7

    View Slide

  18. Leading up to PHP 7
    2012:
    Research PHP+JIT

    begins, led by Dmitry

    Stogov
    2014:

    No performance gains realized for real-
    world workloads

    View Slide

  19. 19
    Jan 2014 Mar 2014
    May
    2014
    Aug
    2014
    • Split from mainstream PHP
    • Internals focus only (no new
    features)
    • Stay 100% compatible
    • Compiled core
    • Ran bench.php
    • Ran WordPress
    • Moved from POC to
    public community project
    • Merged back to
    master as base for
    PHP 7 (after vote)
    Post-JIT Timeline

    View Slide

  20. We Kept Improving It
    • Performance more than doubled since phpng published
    • Perspective: WP homepage, from 9.4bn CPU ops to 2.4bn CPU ops

    View Slide

  21. Hash Table Bucket zVal
    PHP5 PHP7
    20%
    5%
    Memory Manager CPU Overhead (WP)
    Memory Consumption of key Data Structures
    (bytes)
    What Made the Difference?

    View Slide

  22. PHP 7: WHAT’S IN IT FOR ME?

    View Slide

  23. It’s FAST

    View Slide

  24. PHP Performance Evolution

    bench.php (lower is better)
    0 3.5 7 10.5 14
    12.682
    12.537
    4.679
    4.201
    2.911
    2.177
    2.031
    1.92
    0.783
    7.0 (May 2015)
    5.6 (Aug 2014)
    5.5 (Jun 2013)
    5.4 (Mar 2012)
    5.3 (Nov 2009)
    5.2 (Nov 2006)
    5.1 (Nov 2005)
    5.0 (Jul 2004)

    View Slide

  25. Real World Application Benchmarks

    (% improvement vs. PHP 5.6)

    View Slide

  26. Badoo Case Study
    • Estimated $1M plus plus $100K/yr savings on App Server Cluster

    View Slide

  27. More Performance Info
    • http://bit.ly/php7perf
    • http://bit.ly/php7fast
    • http://bit.ly/php7mandel

    View Slide

  28. Engine Exceptions
    • Many E_ERRORS and E_RECOVERABLE_ERRORs are now
    exceptions.
    try {
    call_method(null); // oops!
    } catch (EngineException $e) {
    echo "Exception: {$e->getMessage()}\n";
    }
    • Significantly easier vs. error handler

    View Slide

  29. Return Type Declarations 

    & Scalar Type Hints
    • Declare type of return value of functions

    function foobar(): int {

    return 1.0;

    }
    • New Scalar Type Hints. In two flavors.

    function add(int $a, int $b): int {

    return $a + $b;

    }

    View Slide

  30. Zero Cost assert() (expectations)
    • assert() is a language construct in PHP 7
    – Configurable for dev/prod:
    • zend.assertions = 0 → completely ignored (prod)
    • zend.assertions = 1 → assertions enabled (dev/test)
    – First arg can be an expression
    – Second arg can be an exception

    View Slide

  31. Other Notable New Features
    • The Spaceship Operator
    $x <=> $y
    • Uniform Variable Syntax
    • Abstract Syntax Tree
    • Filtered Unserialize
    • The Null Coalesce operator
    ($x ?? $y) ~= ($x ? $x : $y)
    • Full List: http://bit.ly/php7news
    $foo->$bar['baz']
    $foo->{$bar['baz']} (5.x)
    ($foo->$bar)['baz'] (7.0+)

    View Slide

  32. GOING FORWARD

    View Slide

  33. © All rights reserved. Zend Technologies, Inc.
    
!הדות

    View Slide