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/06/06 09:40] 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 38: 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 44: 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 70: Line 70:
  
 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). 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... 
- 
-==== Alternative syntax (based on simpler variation) ==== 
- 
-This syntax is a shorter alternative (for those who don't like too many lines for parameter parsing): 
- 
-<code> 
-zend_parse_parameters(Z_PARAM_ARRAY(input) Z_PARAM_LONG(offset) Z_PARAM_OPTIONAL Z_PARAM_ZVAL(z_length) Z_PARAM_BOOL(preserve_keys)) 
-</code> 
- 
-or, in the special case where we'd need special failure handling: 
- 
-<code> 
-zend_parse_parameters_ex(Z_PARAM_ARRAY(input) Z_PARAM_LONG(offset) Z_PARAM_OPTIONAL Z_PARAM_ZVAL(z_length) Z_PARAM_BOOL(preserve_keys), { 
-    /* handle failure; */ 
-    return; 
-}) 
-</code> 
  
 ==== Performance Evaluation ==== ==== Performance Evaluation ====
Line 109: Line 78:
 | 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 120: 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 =====
  
-One vote about the proposal in general (use faster version instead of "specifier|list") +State whether this project requires 50%+1 majority (see [[voting]]). The vote is a straight Yes/No vote. 
-  * no +
-  * yes+
  
-One vote about which variation to use: +<doodle title="Should PHP 7 have Fast Parameter Parsing API?" auth="dmitry" voteType="single" closed="true"> 
-  fastest variation (about 0.1% faster, but indicating argument count and required argument count necessary) +   Yes 
-  simpler variation (without indicating argument count, multiline) +   No 
-  * alternative simpler variation (like simpler variation, but multiline)+</doodle>
  
-And one vote about the macro names to use: + The vote concluded on January 27th. 
-  * begin macro names with ZP_* (like ZP_LONG, less verbose name, but maybe more readable in one line) +
-  * begin macro names with Z_PARAM_* (like Z_PARAM_LONG, more verbose name) +
- +
-State whether this project requires 50%+1 majority (see [[voting]])+
  
 ===== 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 + 
-  * Alternative Simpler Variation is just trivial changes on the Simpler Variation patch+The patch is already included into PHP-7 and wrapped with ifdef/ifndef FAST_ZPP.
  
rfc/fast_zpp.1402047648.txt.gz · Last modified: 2017/09/22 13:28 (external edit)