360 likes | 367 Views
Understand the transformation of PHP over the years from PHP 3 to PHP 7.1, emphasizing performance improvements and important new features.
E N D
About Me • 3 daughters • Photography enthusiast • Crazy about spicy foods • Programming since the age of 12 • Last thing I did before getting involved with PHP was C++ CGIs (no!)
PHP 3 Released: June 1998 New Features: Full fledged language Easily extensible
PHP 4 Released: May 2000 New Features: Zend Engine Fast Modular Sessions Downwards compatibility (!) Language plugins
PHP 5 5.0: July 2004 New “true“ object model Not Slower!
What Ended Up Happening Bonus: Roughly doubled memory footprint.
The End http://bit.ly/php6whathappened
Leading up to PHP 7 2012: Research PHP+JITbegins, led by DmitryStogov 2014:No performance gains realized for real-world workloads!
Post-JIT Timeline • Compiled core • Ran bench.php • Ran WordPress • Merged back to master as base for PHP 7 (after vote) • Moved from POC to public community project • Split from mainstream PHP • Internals focus only (no new features) • Stay 100% compatible
What Made the Difference? Memory Consumption of key Data Structures (bytes) Memory Manager CPU Overhead (WP) 20% 5% PHP7 PHP5
Badoo Case Study • Estimated $1M plus plus $100K/yr savings on App Server Cluster
Tumblr Case Study “Not only were our servers serving pages twice as fast, they were doing it using half the amount of CPU resources.”
Real World Application Benchmarks(% improvement vs. PHP 5.6)
Real World Application Benchmarks(% improvement vs. PHP 5.6)
More Info • http://bit.ly/php7perf • http://bit.ly/php7mandel
Easily Recover from Errors • 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
Return Type Declarations & Scalar Type Hints • Declare type of return value of functions<?phpfunctionfoobar():int{return 1.0;} • New Scalar Type Hints. In two flavors.<?phpfunction add(int$a,int$b):int{return$a+$b;}
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
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+)
PHP 7.1 • More Performance Gains • Multi-catch • Void return types • Shortened list() syntax