Skip to content

Zend: Accumulate parsed integer locally in _zend_handle_numeric_str_ex() - #25874

Open
iliaal wants to merge 1 commit into
php:masterfrom
iliaal:opt/handle-numeric-str-local-acc
Open

iliaal wants to merge 1 commit into
php:masterfrom
iliaal:opt/handle-numeric-str-local-acc

Conversation

@iliaal

@iliaal iliaal commented Nov 28, 2026

Copy link
Copy Markdown
Member

_zend_handle_numeric_str_ex() updates *idx on every digit, and because key is a const char * that may alias it, GCC loads and stores *idx on each iteration. Accumulating into a local and storing once at the end removes both from the loop; on ARM64 (Neoverse-N1, GCC 13.3, -O2) a numeric-string key insert and lookup microbenchmark runs about 11% faster.

Comment thread Zend/zend_hash.c Resolved
_zend_handle_numeric_str_ex() updated *idx on every digit. Because key
is a const char * that may alias *idx, GCC loaded and stored *idx on
every loop iteration. Accumulate into a local zend_ulong and store *idx
once at the end of the string.
@iliaal
iliaal force-pushed the opt/handle-numeric-str-local-acc branch from 4d09bb8 to 7225441 Compare November 28, 2026 16:13
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