rfc:fast_zpp

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:fast_zpp [2014/05/23 11:33] dmitryrfc:fast_zpp [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 3: Line 3:
   * Date: 2014-05-23   * Date: 2014-05-23
   * Author: Dmitry Stogov <dmitry@zend.com>, Bob Weinand <bobwei9@hotmail.com>   * Author: Dmitry Stogov <dmitry@zend.com>, Bob Weinand <bobwei9@hotmail.com>
-  * Status: Under Discussion+  * Status: Implemented (PHP 7.0)
   * First Published at: http://wiki.php.net/rfc/fast_zpp   * First Published at: http://wiki.php.net/rfc/fast_zpp
  
Line 16: Line 16:
 ===== Proposal ===== ===== Proposal =====
 We propose an additional fast API for parameter parsing, that should be used for the most useful functions. The API is based on C macros that lead to inlining of optimized code directly into the body of internal function. We propose an additional fast API for parameter parsing, that should be used for the most useful functions. The API is based on C macros that lead to inlining of optimized code directly into the body of internal function.
 +
 +**We don't propose to remove the existing API, and would suggest to use fast API only for most often used functions to get performance boost.**
  
 I'll explain API on the following example: I'll explain API on the following example:
Line 36: Line 38:
 The first code fragment is just taken from PHP_FUNCTION(array_slice), the second is its replacement using new API. The code is actually self explainable. The first code fragment is just taken from PHP_FUNCTION(array_slice), the second is its replacement using new API. The code is actually self explainable.
  
-ZEND_PARSE_PARAMETERS_START() takes two arguments minimal and maximal parameters count. (In general, it's possible to avoid these arguments, but not for free. I'll explain it separate "Simpler Variation" section).+ZEND_PARSE_PARAMETERS_START() takes two arguments minimal and maximal parameters count.
  
 Z_PARAM_ARRAY() - takes the next argument as array, Z_PARAM_LONG - as long, Z_PARAM_OPTIONAL - tells that the remaining arguments are optional. Z_PARAM_ARRAY() - takes the next argument as array, Z_PARAM_LONG - as long, Z_PARAM_OPTIONAL - tells that the remaining arguments are optional.
Line 42: Line 44:
 The new API covers all possibilities of the existing API. The following table shows the correspondence between old specifiers and new macros. The new API covers all possibilities of the existing API. The following table shows the correspondence between old specifiers and new macros.
  
-^ specifier ^ Fast ZPP API macro                ^^+^ specifier ^ Fast ZPP API macro                ^ args ^
 | ''|''     | Z_PARAM_OPTIONAL                  ||                  | ''|''     | Z_PARAM_OPTIONAL                  ||                 
 | a         | Z_PARAM_ARRAY(dest)               | dest - zval* | | a         | Z_PARAM_ARRAY(dest)               | dest - zval* |
Line 67: Line 69:
  
  
-The effect of **!** and **/** modifiers may be achieved using extended version of the same macros e.g. Z_PARAM_ZVAL(dest, check_null, separate)+The effect of **!** and reference modifiers may be achieved using extended version of the same macros e.g. Z_PARAM_ZVAL_EX(dest, check_null, separate).
- +
-==== Simpler Variation ==== +
- +
-It's possible not to specify minimal and maximal arguments in  ZEND_PARSE_PARAMETERS_START() macro, but it leads to some small performance degradation and possible inconsistent error messages when few constraint are broken at same time. For example the following code ''strlen(array(), 1)'' would emit different warning: +
- +
-''Warning: strlen() expects parameter 1 to be string'' +
- +
-however the original PHP would emit +
- +
-''Warning: strlen() expects exactly 1 parameter, 2 given'' +
- +
-This is not a common case. Actually, it breaks just 2 PHPT tests. +
-So the penalties may be accepted in cost of usability. +
-On the other hand these number need to be written just once...+
  
 ==== Performance Evaluation ==== ==== Performance Evaluation ====
  
-The following numers collected for 100 and 1000 requests to wordpress home page.+The following numbers collected for 100 and 1000 requests to wordpress home page.
  
 ^                          ^ # of CPU instructions ^ time [sec] ^ ^                          ^ # of CPU instructions ^ time [sec] ^
 | phpng                    |          5,132,181,672|       18.90| | phpng                    |          5,132,181,672|       18.90|
 | phpng + fast_zpp                  4,901,907,204|       18.40| | phpng + fast_zpp                  4,901,907,204|       18.40|
-| phpng + simple variation |          4,906,486,678|       18.40| 
  
  
Line 101: Line 88:
  
 ===== Proposed PHP Version(s) ===== ===== Proposed PHP Version(s) =====
-This proposal is targeted to phpng+This proposal is targeted to php-7
  
-===== Proposed Voting Choices =====+===== Vote =====
  
-  * no +State whether this project requires 50%+1 majority (see [[voting]]). The vote is a straight Yes/No vote. 
-  * yes +
-  * yes for simpler variation+
  
-State whether this project requires 50%+1 majority (see [[voting]])+<doodle title="Should PHP 7 have Fast Parameter Parsing API?" auth="dmitry" voteType="single" closed="true"> 
 +   * Yes 
 +   * No 
 +</doodle> 
 + 
 + The vote concluded on January 27th. 
  
 ===== Patches and Tests ===== ===== Patches and Tests =====
  
   * Original Proposal: https://gist.github.com/dstogov/1131691470a4c37540a6   * Original Proposal: https://gist.github.com/dstogov/1131691470a4c37540a6
-  * Simpler Variation: https://gist.github.com/dstogov/843a3df3149761a59f21+ 
 +The patch is already included into PHP-7 and wrapped with ifdef/ifndef FAST_ZPP.
  
rfc/fast_zpp.1400844822.txt.gz · Last modified: 2017/09/22 13:28 (external edit)