Skip to content

zend_types: Convert HT_*() macros to inline functions#22305

Open
TimWolla wants to merge 1 commit into
php:masterfrom
TimWolla:zend-types-ht-demacro
Open

zend_types: Convert HT_*() macros to inline functions#22305
TimWolla wants to merge 1 commit into
php:masterfrom
TimWolla:zend-types-ht-demacro

Conversation

@TimWolla

Copy link
Copy Markdown
Member

No description provided.

@TimWolla

Copy link
Copy Markdown
Member Author

For this one the benchmarking job shows a meaningful increase in instructions. It's not clear to me why 🤔

@TimWolla TimWolla force-pushed the zend-types-ht-demacro branch from be6b99d to e41b1af Compare June 14, 2026 16:56
@github-actions

Copy link
Copy Markdown

AWS x86_64 (c6id.metal)

Attribute Value
Environment aws
Instance type c6id.metal
Architecture x86_64
CPU Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz, 64 cores @ 2900 MHz
CPU settings disabled deeper C-states, disabled turbo boost, disabled hyper-threading
RAM 251 GB
Kernel 6.18.20-20.229.amzn2023.x86_64
OS Amazon Linux 2023.11.20260427
GCC 14.2.1
Time 2026-06-14 17:01:29 UTC
Job details https://github.com/php/php-src/actions/runs/27505874389 (Artifacts)
Changeset https://github.com/php/php-src/compare/951680712b..e41b1af644

Laravel 12.11.0 demo app - 50 iterations, 50 warmups, 100 requests (sec)

PHP Min Max Std dev Rel std dev % Mean Mean diff % Median Median diff % Skewness Z-stat P-value Memory
PHP - baseline@9516807 0.38628 0.38721 0.00020 0.05% 0.38673 0.00% 0.38671 0.00% 0.321 0.000 1.000 25.82 MB
PHP - zend-types-ht-demacro 0.38783 0.38910 0.00028 0.07% 0.38818 0.38% 0.38813 0.37% 1.582 -8.614 0.000 25.82 MB

Symfony 2.8.0 demo app - 50 iterations, 50 warmups, 100 requests (sec)

PHP Min Max Std dev Rel std dev % Mean Mean diff % Median Median diff % Skewness Z-stat P-value Memory
PHP - baseline@9516807 0.66771 0.66945 0.00034 0.05% 0.66816 0.00% 0.66810 0.00% 1.530 0.000 1.000 25.92 MB
PHP - zend-types-ht-demacro 0.67150 0.67614 0.00071 0.11% 0.67230 0.62% 0.67215 0.60% 3.838 -8.614 0.000 25.88 MB

Wordpress 6.9 main page - 50 iterations, 20 warmups, 20 requests (sec)

PHP Min Max Std dev Rel std dev % Mean Mean diff % Median Median diff % Skewness Z-stat P-value Memory
PHP - baseline@9516807 0.58724 0.59001 0.00068 0.12% 0.58789 0.00% 0.58769 0.00% 1.813 0.000 1.000 26.32 MB
PHP - zend-types-ht-demacro 0.59001 0.59452 0.00080 0.14% 0.59073 0.48% 0.59054 0.49% 3.487 -8.607 0.000 25.90 MB

bench.php - 50 iterations, 20 warmups, 2 requests (sec)

PHP Min Max Std dev Rel std dev % Mean Mean diff % Median Median diff % Skewness Z-stat P-value Memory
PHP - baseline@9516807 0.44958 0.45289 0.00061 0.13% 0.45083 0.00% 0.45080 0.00% 0.851 0.000 1.000 26.32 MB
PHP - zend-types-ht-demacro 0.44957 0.45320 0.00071 0.16% 0.45085 0.00% 0.45080 0.00% 0.810 0.000 1.000 25.90 MB

micro_bench.php - 50 iterations, 5 warmups, 1 request (sec)

PHP Min Max Std dev Rel std dev % Mean Mean diff % Median Median diff % Skewness Z-stat P-value Memory
PHP - baseline@9516807 1.27251 1.31261 0.00688 0.54% 1.28142 0.00% 1.27996 0.00% 2.909 0.000 1.000 26.32 MB
PHP - zend-types-ht-demacro 1.27062 1.28890 0.00370 0.29% 1.28029 -0.09% 1.28015 0.01% -0.336 -0.052 0.959 25.90 MB

@ndossche

ndossche commented Jun 14, 2026

Copy link
Copy Markdown
Member

With macros, functions like zend_hash_real_init (& co) can use the specialised emalloc_ functions.
These functions can only be used if the size expression is a constant; otherwise it degrades to a generic emalloc call.
__builtin_constant_p fails for the function call because... well it isn't a constant. And the optimizer eventually makes it a constant but that's too late for __builtin_constant_p to kick in.
You can validate that by looking at the assembly for those functions.
Similar effects can happen with efree.
EDIT: pure or const attribute would work: https://godbolt.org/z/T4n8jjc9Y

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants