Page 1
Better & faster
Bruno Ricardo Siqueira
2015
Page 2
ABOUT THE SPEAKER
Bruno Ricardo Siqueira.
Web developer and PHP evangelist in Brazil. Docker enthusiast. Git heavy user.
Working with Web Development for the last 8 years, Bachelor in Information Systems by University of Sao Paulo ICMC - USP, currently working at CI&T as Software Engineer.
Page 3
AGENDA
● Warming-up
○ Contextualization
○ Deprecations
○ Removals &
inconsistency reduction
● Looking inside
○ Memory
○ Performance
● New features
○ Unicode
○ Exception in the core
○ Anonymous classes
○ Operators
○ Declarations
○ Generators
● Near future & conclusions
● Questions
Page 5
WARMING-UP - CONTEXTUALIZATION
● 2009 - PHP 5.3
○ Namespaces
○ Anonymous functions
● 2009 - PHP-FIG
● 2010 - HipHop for PHP
(HPHPc)
○ PHP -> C++ binary
● 2011 - HipHop Virtual Machine
(HHVM)
○ JIT -> HipHop ByteCode
● 2012 - PHP 5.4
○ Traits
○ Built in Webserver
● 2013 - PHP 5.5
○ Generators
○ OpCache in the core
● 2014 - HACK Language
● 2014 - PHP 5.6
○ Variadic Functions (...)
○ reusable php://input
Page 7
WARMING-UP - CONTEXTUALIZATION
Page 8
WARMING-UP - CONTEXTUALIZATION
Page 9
WARMING-UP - CONTEXTUALIZATION
Page 10
WARMING-UP - CONTEXTUALIZATION
Page 12
● PHP 4 constructors
● password_hash() option
WARMING-UP - DEPRECATIONS
Page 13
WARMING-UP - REMOVALS & INCONSISTENCY REDUCTION
● date.timezone warning:
○ default value
● alternative tags:
○ <% opening tag○ <%= opening tag with echo○ %> closing tag○ (<script\s+language\s*=\s*(php|"php"|'php')\s*>)i
opening tag○ (</script>)i closing tag
● multiple default blocks in switch constructions
Page 14
WARMING-UP - REMOVALS & INCONSISTENCY REDUCTION
● SAPIs & extensions:
○ sapi/aolserver, sapi/apache, sapi/apache_hooks, sapi/apache2filter, sapi/caudium, sapi/continuity, sapi/isapi, sapi/milter, sapi/nsapi, sapi/phttpd, sapi/pi3web, sapi/roxen, sapi/thttpd, sapi/tux, sapi/webjames, ext/mssql, ext/mysql, ext/sybase_ct, ext/ereg
○ moved to PECL
● hexadecimals in numeric strings
● E_STRICT Notices
Page 15
WARMING-UP - REMOVALS & INCONSISTENCY REDUCTION
● Uniform Variable Syntax
Page 18
LOOKING INSIDE - MEMORY
Page 19
LOOKING INSIDE - PERFORMANCE
● ZVALs PHP 5.X
○ (almost) always heap
allocated
○ reference counted &
cycle colletcion
○ duplicated refcount
(objects)
○ too much referencing, e.
g.: 1 object in 1 variable ->
4 pointers
● ZVALs PHP 7
○ simple values (int, bool…)
without head allocation &
without refcount
○ no more double refcount.
○ reusable values
independent of zval
structure
Page 20
Smaller data structures.Less allocations.Less referencing.
BETTER PERFORMANCE!
LOOKING INSIDE - PERFORMANCE
Page 23
100% of performance improvement
in real world
applications
Page 25
NEW FEATURES - UNICODE
Page 26
NEW FEATURES - EXCEPTIONS IN THE CORE
Page 27
NEW FEATURES - EXCEPTIONS IN THE CORE
Page 28
NEW FEATURES - EXCEPTIONS IN THE CORE
Page 29
NEW FEATURES - EXCEPTIONS IN THE CORE
Page 30
NEW FEATURES - EXCEPTIONS IN THE CORE
Page 31
NEW FEATURES - ANONYMOUS CLASSES
Page 32
NEW FEATURES - OPERATORS spaceship operator <=>
Page 33
NEW FEATURES - OPERATORS spaceship operator <=>
Page 34
NEW FEATURES - OPERATORS spaceship operator <=>
Page 35
NEW FEATURES - OPERATORS spaceship operator <=>
Page 36
NEW FEATURES - OPERATORS spaceship operator <=>
Page 37
NEW FEATURES - OPERATORS spaceship operator <=>
Page 38
NEW FEATURES - OPERATORS spaceship operator <=>
Page 39
NEW FEATURES - OPERATORS null coalesce operator ??
Page 40
NEW FEATURES - OPERATORS null coalesce operator ??
Page 41
NEW FEATURES - OPERATORS null coalesce operator ??
Page 42
NEW FEATURES - OPERATORS null coalesce operator ??
Page 43
NEW FEATURES - DECLARATIONS scalar types
Page 44
NEW FEATURES - DECLARATIONS scalar types
Page 45
NEW FEATURES - DECLARATIONS return types
Page 46
NEW FEATURES - DECLARATIONS return types
Page 47
NEW FEATURES - DECLARATIONS return types
Page 48
NEW FEATURES - DECLARATIONS return types
Page 49
NEW FEATURES - DECLARATIONS return types
Page 50
NEW FEATURES - DECLARATIONS return types
Page 51
NEW FEATURES - DECLARATIONS return types
Page 52
NEW FEATURES - DECLARATIONS return types
Page 53
NEW FEATURES - DECLARATIONS return types
Page 54
NEW FEATURES - DECLARATIONS return types
Page 55
NEW FEATURES - DECLARATIONS group use
Page 56
NEW FEATURES - DECLARATIONS group use
Page 57
NEW FEATURES - DECLARATIONS group use
Page 58
NEW FEATURES - DECLARATIONS group use
Page 59
NEW FEATURES - DECLARATIONS group use
Page 60
NEW FEATURES - DECLARATIONS group use
Page 61
NEW FEATURES - GENERATORS return expressions
Page 62
NEW FEATURES - GENERATORS return expressions
Page 63
NEW FEATURES - GENERATORS return expressions
Page 64
NEW FEATURES - GENERATORS return expressions
Page 65
NEW FEATURES - GENERATORS return expressions
Page 66
NEW FEATURES - GENERATORS return expressions
Page 67
NEW FEATURES - GENERATORS return expressions
Page 68
NEW FEATURES - GENERATORS delegating generator
Page 69
NEW FEATURES - GENERATORS delegating generator
Page 70
NEW FEATURES - GENERATORS delegating generator
Page 71
NEW FEATURES - GENERATORS delegating generator
Page 72
NEW FEATURES - GENERATORS delegating generator
Page 73
NEW FEATURES - GENERATORS delegating generator
Page 74
NEW FEATURES - GENERATORS delegating generator
Page 75
NEW FEATURES - GENERATORS delegating generator
return expressions + delegating generator…
Can you see the concurrency?
Page 76
Lightweight Threads
FTW!
Page 77
NEAR FUTURE & CONCLUSIONS
Page 79
FUTURO PRÓXIMO
● PSR7 + Middleware pattern will
boost even more the PHP
packages reusability
● JIT + PHP Virtual Machine
● Language specification
● Better consistency
● AST will bring new/better
static analysis tools
● ...
Page 82
THANKS FOR
BEINGHERE!
PHP7: better & faster
References: http://bit.ly/tdcsp-2015-php7
BRUNO RICARDO SIQUEIRA
@brunoric
https://joind.in/14853