Uh oh!
There was an error while loading. Please reload this page.
ZPP: Return tristate from zend_parse_arg_bool_weak() - #21739
Conversation
AWS x86_64 (c6id.metal)
Laravel 12.11.0 demo app - 50 iterations, 50 warmups, 100 requests (sec)
Symfony 2.8.0 demo app - 50 iterations, 50 warmups, 100 requests (sec)
Wordpress 6.9 main page - 50 iterations, 20 warmups, 20 requests (sec)
bench.php - 50 iterations, 20 warmups, 2 requests (sec)
|
iluuu1994
left a comment
There was a problem hiding this comment.
Nice! Looks to be profitable.
| @@ -2173,21 +2173,27 @@ ZEND_API ZEND_COLD void zend_class_redeclaration_error_ex(int type, zend_string | |||
| /* Inlined implementations shared by new and old parameter parsing APIs */ | |||
| typedef enum ZPP_PARSE_BOOL_STATUS { | |||
There was a problem hiding this comment.
Should just be zpp_parse_bool_status.
| @@ -2173,21 +2173,27 @@ ZEND_API ZEND_COLD void zend_class_redeclaration_error_ex(int type, zend_string | |||
| /* Inlined implementations shared by new and old parameter parsing APIs */ | |||
| typedef enum ZPP_PARSE_BOOL_STATUS { | |||
| ZPP_PARSE_AS_FALSE = 0, | |||
There was a problem hiding this comment.
IMO, should have a consistent prefix, i.e. ZPP_PARSE_BOOL_STATUS_FALSE.
| if (EXPECTED(Z_TYPE_P(arg) <= IS_STRING)) { | ||
| if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("bool", arg_num)) { | ||
| return 0; | ||
| return ZPP_PARSE_ERROR; | ||
| } | ||
| *dest = zend_is_true(arg); | ||
| } else { | ||
| return 0; | ||
| return zend_is_true(arg); | ||
| } | ||
| return 1; | ||
| return ZPP_PARSE_ERROR; |
There was a problem hiding this comment.
Happy path sandwich. Maybe:
if (UNEXPECTED(Z_TYPE_P(arg) >IS_STRING)) {
returnZPP_PARSE_ERROR;
}
if (UNEXPECTED(Z_TYPE_P(arg) ==IS_NULL) && !zend_null_arg_deprecated("bool", arg_num)) {
returnZPP_PARSE_ERROR;
}
returnzend_is_true(arg);| } else { | ||
| return zend_parse_arg_str_slow(arg, dest, arg_num); | ||
| return 0; |
There was a problem hiding this comment.
Consistent handling with the other cases? I.e. write to and check *dest without a branch? This won't work for zpp_parse_bool_status because of bool coercion, but should work here.
Uh oh!
There was an error while loading. Please reload this page.
90efcd9 to
5c689b4CompareAWS x86_64 (c6id.metal)
Laravel 12.11.0 demo app - 50 iterations, 50 warmups, 100 requests (sec)
Symfony 2.8.0 demo app - 50 iterations, 50 warmups, 100 requests (sec)
Wordpress 6.9 main page - 50 iterations, 20 warmups, 20 requests (sec)
bench.php - 50 iterations, 20 warmups, 2 requests (sec)
|
Girgias
commented
Apr 14, 2026
@iluuu1994 so either something in the review comment drastically changed how profitable it is, or the benchmarks have too much noise/jitter :| |
5c689b4 to
f5e072dCompareAWS x86_64 (c6id.metal)
Laravel 12.11.0 demo app - 50 iterations, 50 warmups, 100 requests (sec)
Symfony 2.8.0 demo app - 50 iterations, 50 warmups, 100 requests (sec)
Wordpress 6.9 main page - 50 iterations, 20 warmups, 20 requests (sec)
bench.php - 50 iterations, 20 warmups, 2 requests (sec)
|
AWS x86_64 (c6id.metal)
Laravel 12.11.0 demo app - 50 iterations, 50 warmups, 100 requests (sec)
Symfony 2.8.0 demo app - 50 iterations, 50 warmups, 100 requests (sec)
Wordpress 6.9 main page - 50 iterations, 20 warmups, 20 requests (sec)
bench.php - 50 iterations, 20 warmups, 2 requests (sec)
|
3fea5ce to
0f406e0Compare0f406e0 to
7bfbf8eCompareUh oh!
There was an error while loading. Please reload this page.
Follow-up PR on top of #21737.
This idea is based on @ndossche previous PR to reduce codebloat: #18436
This effectively allows us to return the boolean value via the return type rather than using an out pointer.