Re: Improved performance of array_maerge() and func_get_args()
2013/10/23 Dmitry Stogov <[email protected]>:
> Hi,
>
> I'm proposing two simple patches that eliminate a lot of useless zval
> copying.
> For example they remove only about 800 calls to zend_hash_copy() (25%) on
> each request to wordpress-3.6.0 home page and make it 2-4% faster.
>
> It's not a questions about master branch, but I think it is also safe to
> commit them into PHP-5.4 and PHP-5.5.
>
> Any objections?
>
> https://gist.github.com/dstogov/7117623
>
> https://gist.github.com/dstogov/7117649
>
> Thanks. Dmitry.
That sounds really good.
Note that in many performance investigations I made, array_merge() was
often one of the cause of some unnecessary overhead, however, most of
the times this function was used was in fact to merge arrays that were
in fact *hashes* (dictionary, map,...) and not really *arrays*. In
those cases, the performance fix is simply to use "$y + $x" instead of
"array_merge($x, $y).
Are all those array_merge() of wordpress really made to merge *arrays*
rather than *hashes*?
Is the gain constant for all cases of array_merge(), with numeric
indices vs string ones?
Patrick
Thread (14 messages)