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. • 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
  2. PHP 3.0 • Released: June 1998 • New Features: •

    Full fledged language • Extensions
  3. PHP 4.0 • Released: May 2000 • New Features: •

    Zend Engine • Modularity • Sessions • Downwards compatibility (!) • Language plugins
  4. PHP 5 • 5.0: July 2004 • New Features: •

    New “true“ object model • Destructors • Exception handling • Not Slower • Seeds were sown...
  5. 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)
  6. 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)
  7. 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.
  8. Leading up to PHP 7 2012: Research PHP+JIT
 begins, led

    by Dmitry
 Stogov 2014:
 No performance gains realized for real- world workloads
  9. 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
  10. We Kept Improving It • Performance more than doubled since

    phpng published • Perspective: WP homepage, from 9.4bn CPU ops to 2.4bn CPU ops
  11. Hash Table Bucket zVal PHP5 PHP7 20% 5% Memory Manager

    CPU Overhead (WP) Memory Consumption of key Data Structures (bytes) What Made the Difference?
  12. 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)
  13. 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
  14. Return Type Declarations 
 & Scalar Type Hints • Declare

    type of return value of functions
 <?php 
 function foobar(): int {
 return 1.0;
 } • New Scalar Type Hints. In two flavors.
 <?php
 function add(int $a, int $b): int {
 return $a + $b;
 }
  15. 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
  16. 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+)