Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69817 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8579 invoked from network); 23 Oct 2013 19:23:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Oct 2013 19:23:46 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain zend.com from 209.85.212.172 cause and error) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.212.172 mail-wi0-f172.google.com Received: from [209.85.212.172] ([209.85.212.172:50014] helo=mail-wi0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 08/17-10840-14228625 for ; Wed, 23 Oct 2013 15:23:46 -0400 Received: by mail-wi0-f172.google.com with SMTP id ez12so7905893wid.17 for ; Wed, 23 Oct 2013 12:23:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=hnsaPe3TyQbaaRv92Rh0IG1/1PU3qFrGE/O3DFiwSns=; b=CsCAEc5kX+MZAGdyiyrpXtXGkXI9Z1Jp5oyYw/bKAG28q8kcfznEVSib571gY2oeVj XMM0zfd9SMk5eKFqchqppBGkpVX0gglKuwIbCZJn4iZN0dCtkXWO7dBjLVdAZ8fak5sp kfN3x14a6/27o5L0jpIAsd4giq2fQ+8scUxpflyYJpXkOWk5W08cnEgUHQ4ZGs9i830B ctykoRhyfOWExLxV4nUg1Y58CGzQvcy7B9GFW+dKsBnbGoDaKUwd8nGLy4GSAF26WK1X 7y8Kk9oMcNqp9zteCBnAwevniS7z4nVrBJWEgFaRf2YUBFbDqso6XlDuzJW77g0gAr8A D1Aw== X-Gm-Message-State: ALoCoQlNi2ANXQcIyXNxFpEMe4n0CX8gChtAyGwnUx6e2x9B4Ugz5BRbpD7qQtse4T54t608jvL+XF2Z/eKEYpaOssB33yMjV86Vux1qzf0c4afXSKdewXA+UKZIlTCVxWRuA+21a+XQ MIME-Version: 1.0 X-Received: by 10.180.73.239 with SMTP id o15mr3464662wiv.36.1382556223366; Wed, 23 Oct 2013 12:23:43 -0700 (PDT) Received: by 10.227.214.144 with HTTP; Wed, 23 Oct 2013 12:23:43 -0700 (PDT) In-Reply-To: References: Date: Wed, 23 Oct 2013 23:23:43 +0400 Message-ID: To: Patrick ALLAERT Cc: Julien Pauli , David Soria Parra , Stas Malyshev , PHP Internals Content-Type: multipart/alternative; boundary=f46d0435c0089384ce04e96d74a4 Subject: Re: [PHP-DEV] Improved performance of array_maerge() and func_get_args() From: dmitry@zend.com (Dmitry Stogov) --f46d0435c0089384ce04e96d74a4 Content-Type: text/plain; charset=UTF-8 No. the array_merge() patch doesn't change the algorithm. We just discovered that array_merge() makes a copy of each element of each array before the actual merging, and in case it's an array or object, it may take significant time, but this copying is absolutely useless. The patch just remove it. Thanks. Dmitry. On Wed, Oct 23, 2013 at 10:10 PM, Patrick ALLAERT wrote: > 2013/10/23 Dmitry Stogov : > > 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 > --f46d0435c0089384ce04e96d74a4--