ext/standard: Various minor optimizations (2026-9) - #23690
LamentXU123 wants to merge 5 commits into
Conversation
|
as far as array_chunk optimisation goes, this PR seems to go deeper. |
|
Oh I didn't see that PR. I will revert array_chunk optimisation here since that PR seems to cover all my optimizations in this PR. |
Integer keys are copied unchanged from the input and remain unique in the new result. Use zend_hash_index_add_new() to avoid redundant checks.
Parsed fields are appended sequentially to a new array. Use append-new insertion for the fields and for the single-value blank-line result.
Repeated option values accumulate in private arrays that are only appended to. New option keys are inserted after a failed lookup. Use known-new insertion helpers for both cases.
Each call builds a new result with distinct fixed field names. Use zend_hash_add_new() for these fields.
15f2da5 to
290258a
Compare
iliaal
left a comment
There was a problem hiding this comment.
Looks good, nice to see focus on performance, thanks!
| } | ||
|
|
||
| array_init(return_value); | ||
| array_init_size(return_value, 26); |
There was a problem hiding this comment.
Optional: derive this from the table like filestat.c does, 2 * (sizeof(stat_sb_names) / sizeof(*stat_sb_names)), so the two can't drift.
There was a problem hiding this comment.
I think this is correct :) Thanks.
|
I did benchmark on my own, seems only *stat() calls demonstrate noticeable positive differences, the rest is within noise. Might be nice to publish yours. |
About the same here, but semantically changes look right to me, so on that basis I think ok for 8.6 |
|
Fair. Anyhow, it is more up to gina here :) |
stat(), lstat() and fstat() return 13 integer keys and 13 string keys. Allocate a mixed table for all 26 entries up front to avoid growing and converting an intermediate packed array. Use append-new insertion for the unique numeric keys.
290258a to
2b636d0
Compare
|
Mostly the optimizations are minor so it's hardly observable. IMO this is correct from the C-side and assembly-side. cc @Girgias |
Commits should be reviewed separately. The optimization is mostly using *_new() function for less unnecessary checks.