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 full-size 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 full-size slide

  3. How I got involved

    View full-size slide

  4. A Humble Beginning
    4

    View full-size slide

  5. PHP’s popular. Really.

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  9. 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 full-size slide

  10. 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 full-size slide

  11. Full Language-Level Unicode

    View full-size slide

  12. 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 full-size slide

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

    View full-size slide

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

    begins, led by Dmitry

    Stogov
    2014:

    No performance gains realized for real-
    world workloads

    View full-size slide

  15. 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 full-size slide

  16. 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 full-size slide

  17. 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 full-size slide

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

    View full-size slide

  19. 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 full-size slide

  20. Real World Application Benchmarks

    (% improvement vs. PHP 5.6)

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  23. 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 full-size slide

  24. 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 full-size slide

  25. 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 full-size slide

  26. 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 full-size slide

  27. GOING FORWARD

    View full-size slide

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

    View full-size slide