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 ואת היכולות המרכזיות החדשות של השפה.

A8aeb5f617d6089ba16348881905b54e?s=128

WordCamp Israel

March 28, 2016
Tweet

More Decks by WordCamp Israel

Other Decks in Programming

Transcript

  1. Zeev Suraski
 WordCamp Israel 2016

  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
  3. How I got involved

  4. A Humble Beginning 4

  5. PHP’s popular. Really.

  6. EVOLUTION

  7. PHP 3.0 • Released: June 1998 • New Features: •

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

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

    New “true“ object model • Destructors • Exception handling • Not Slower • Seeds were sown...
  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)
  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)
  12. PHP 6

  13. The Premise

  14. Full Language-Level Unicode

  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.
  16. The End http://bit.ly/php6whathappened

  17. PHP 7

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

    by Dmitry
 Stogov 2014:
 No performance gains realized for real- world workloads
  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
  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
  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?
  22. PHP 7: WHAT’S IN IT FOR ME?

  23. It’s FAST

  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)
  25. Real World Application Benchmarks
 (% improvement vs. PHP 5.6)

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

    on App Server Cluster
  27. More Performance Info • http://bit.ly/php7perf • http://bit.ly/php7fast • http://bit.ly/php7mandel

  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
  29. 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;
 }
  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
  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+)
  32. GOING FORWARD

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