Download - PHP7.1 New Features & Performance
![Page 1: PHP7.1 New Features & Performance](https://reader034.vdocuments.us/reader034/viewer/2022042723/587ac7341a28ab760f8b49e3/html5/thumbnails/1.jpg)
PHP7.1 New Features & Performance@Laruence
![Page 2: PHP7.1 New Features & Performance](https://reader034.vdocuments.us/reader034/viewer/2022042723/587ac7341a28ab760f8b49e3/html5/thumbnails/2.jpg)
About Me• Author of Yaf, Yar, Yac, Yaconf, Taint, Lua, etc
• Maintainer of APC, Zend Opcache, Msgpack
• PHP core developer since 2011
• Zend consultant since 2013
• Core author of PHP7
• Chief Architect at Lianjia
![Page 3: PHP7.1 New Features & Performance](https://reader034.vdocuments.us/reader034/viewer/2022042723/587ac7341a28ab760f8b49e3/html5/thumbnails/3.jpg)
PHP• 20 years history
• Most popular Web service program language
• Over 82% sites are use PHP as server side program language
• Latest version is PHP-7.1
![Page 4: PHP7.1 New Features & Performance](https://reader034.vdocuments.us/reader034/viewer/2022042723/587ac7341a28ab760f8b49e3/html5/thumbnails/4.jpg)
PHP71• Nullable types
• Void return type
• Iterable pseudo-type
• Class constant visibility modifiers
• Specify keys in list()
• Square bracket syntax for list()
• Catching multiple exception types
• Missing arguments Excetpion
• Warn about invalid strings in arithmetic
• Generalize support of negative string offsets
• ….
![Page 5: PHP7.1 New Features & Performance](https://reader034.vdocuments.us/reader034/viewer/2022042723/587ac7341a28ab760f8b49e3/html5/thumbnails/5.jpg)
Nullable types• An enhancement for typehints
return type parameters
![Page 6: PHP7.1 New Features & Performance](https://reader034.vdocuments.us/reader034/viewer/2022042723/587ac7341a28ab760f8b49e3/html5/thumbnails/6.jpg)
Void return types• An enhancement for return type hint
![Page 7: PHP7.1 New Features & Performance](https://reader034.vdocuments.us/reader034/viewer/2022042723/587ac7341a28ab760f8b49e3/html5/thumbnails/7.jpg)
Iterable Pseudo type• Iterable accepts any array or object implementing Traversable
• Iterable can also be used in return type
![Page 8: PHP7.1 New Features & Performance](https://reader034.vdocuments.us/reader034/viewer/2022042723/587ac7341a28ab760f8b49e3/html5/thumbnails/8.jpg)
Class constant visibility modifiers• Support class constant visibility
![Page 9: PHP7.1 New Features & Performance](https://reader034.vdocuments.us/reader034/viewer/2022042723/587ac7341a28ab760f8b49e3/html5/thumbnails/9.jpg)
Specify keys in list()• An enhancement for list()
• Also works in foreach
specify keys in list specify keys in list with foreach
![Page 10: PHP7.1 New Features & Performance](https://reader034.vdocuments.us/reader034/viewer/2022042723/587ac7341a28ab760f8b49e3/html5/thumbnails/10.jpg)
Square backtrace for list()• Continuation syntax for short array syntax introduced in 5.4
• Also works in foreach too
![Page 11: PHP7.1 New Features & Performance](https://reader034.vdocuments.us/reader034/viewer/2022042723/587ac7341a28ab760f8b49e3/html5/thumbnails/11.jpg)
Catching multiply exception types• Allow catching multiply exception types in single catch
normal way PHP71 way
![Page 12: PHP7.1 New Features & Performance](https://reader034.vdocuments.us/reader034/viewer/2022042723/587ac7341a28ab760f8b49e3/html5/thumbnails/12.jpg)
Missing arguments exception• Disable calling “user” functions with insufficient actual parameters
before 71
after 71
![Page 13: PHP7.1 New Features & Performance](https://reader034.vdocuments.us/reader034/viewer/2022042723/587ac7341a28ab760f8b49e3/html5/thumbnails/13.jpg)
Warn about invalid strings in arithmetic
• Produce E_NOTICE or E_WARNING when using invalid numeric strings with arithmetic operators
![Page 14: PHP7.1 New Features & Performance](https://reader034.vdocuments.us/reader034/viewer/2022042723/587ac7341a28ab760f8b49e3/html5/thumbnails/14.jpg)
Generalize support of negative string offsets
• Support of negative string offsets when it make sense
![Page 15: PHP7.1 New Features & Performance](https://reader034.vdocuments.us/reader034/viewer/2022042723/587ac7341a28ab760f8b49e3/html5/thumbnails/15.jpg)
One More thing
![Page 16: PHP7.1 New Features & Performance](https://reader034.vdocuments.us/reader034/viewer/2022042723/587ac7341a28ab760f8b49e3/html5/thumbnails/16.jpg)
PHP71 Performance• Over 10% Perfromance improvement
0.901
1.022
2.991
3.045
3.102
3.762
5.318
6.527
13.424
0 2 4 6 8 10 12 14 16
PHP-7.1
PHP-7.0
PHP-5.6
PHP-5.5
PHP-5.4
PHP-5.3
PHP-5.2
PHP-5.1
PHP-5.0
bench.php�
![Page 17: PHP7.1 New Features & Performance](https://reader034.vdocuments.us/reader034/viewer/2022042723/587ac7341a28ab760f8b49e3/html5/thumbnails/17.jpg)
Type specific opcode handlers
ZEND_ADD
ZEND_ADD_LONG_LONG
![Page 18: PHP7.1 New Features & Performance](https://reader034.vdocuments.us/reader034/viewer/2022042723/587ac7341a28ab760f8b49e3/html5/thumbnails/18.jpg)
Type Inference system• Part work of our JIT in 2013
normal branch loop
![Page 19: PHP7.1 New Features & Performance](https://reader034.vdocuments.us/reader034/viewer/2022042723/587ac7341a28ab760f8b49e3/html5/thumbnails/19.jpg)
Static Single-Assignment Form• An intermediate representation, variable is assigned exactly once
• Explicit use-def chain
![Page 20: PHP7.1 New Features & Performance](https://reader034.vdocuments.us/reader034/viewer/2022042723/587ac7341a28ab760f8b49e3/html5/thumbnails/20.jpg)
Type Inference• What’s ? ’s type at ? point
• Computed in compiling time
![Page 21: PHP7.1 New Features & Performance](https://reader034.vdocuments.us/reader034/viewer/2022042723/587ac7341a28ab760f8b49e3/html5/thumbnails/21.jpg)
Type Specific opcode handler• Use type specific opcode handler if possible
![Page 22: PHP7.1 New Features & Performance](https://reader034.vdocuments.us/reader034/viewer/2022042723/587ac7341a28ab760f8b49e3/html5/thumbnails/22.jpg)
Type Inference system• A tedious work
• And we can only get ~30% type-infos in WP
![Page 23: PHP7.1 New Features & Performance](https://reader034.vdocuments.us/reader034/viewer/2022042723/587ac7341a28ab760f8b49e3/html5/thumbnails/23.jpg)
Type Specific opcode handlers• ZEND_ADD(SUB|MUL)
• ZEND_PRE_INC(DEC)
• ZEND_POST_INC(DEC)
• ZEND_IS_(NOT_)EQUAL
• ZEND_IS_SMALLER(_OR_EQUAL)
• ZEND_QM_ASSIGN
• ZEND_SEND_VAR(_EX)
• ZEND_FETCH_DIM_R
![Page 24: PHP7.1 New Features & Performance](https://reader034.vdocuments.us/reader034/viewer/2022042723/587ac7341a28ab760f8b49e3/html5/thumbnails/24.jpg)
And dozens of minor improvements• More packed array constructions
• Constant propagation based on DFA
• Return type checks eliding
• dozens of minor improvements even I can not recall
![Page 25: PHP7.1 New Features & Performance](https://reader034.vdocuments.us/reader034/viewer/2022042723/587ac7341a28ab760f8b49e3/html5/thumbnails/25.jpg)
Q&A