Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69812 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98009 invoked from network); 23 Oct 2013 18:10:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Oct 2013 18:10:20 -0000 Authentication-Results: pb1.pair.com smtp.mail=patrick.allaert@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=patrick.allaert@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.181 as permitted sender) X-PHP-List-Original-Sender: patrick.allaert@gmail.com X-Host-Fingerprint: 209.85.214.181 mail-ob0-f181.google.com Received: from [209.85.214.181] ([209.85.214.181:39800] helo=mail-ob0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EA/F4-10840-C0118625 for ; Wed, 23 Oct 2013 14:10:20 -0400 Received: by mail-ob0-f181.google.com with SMTP id va2so1403864obc.26 for ; Wed, 23 Oct 2013 11:10:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=DK2DNEMA1deQ+ptiVvSpBupqAmeHVujzhCJ9T/UvChU=; b=dwlq9/WXKMeNrYArHKe2+3xI+kRHJen7NF/al04NcAfVFM1zwb/1eqMvqORduiW3F1 RmkKfLIzS58N5k+X36g4x7krdYL7HmbAREjBWMcVVu6qtqWCbC5fzzTK5viOSVBcdMqk 52QbJ4iAw4HyEWOaY3te3Q9WgCHDbgwQgKp/tJ3oktRqHFHGOAfI4rHdbdTzvbSnGx3z UQGHU64goABzsGmTIrIgMLW0WbY7IKrNZrE5kCxA2myN0fDExRyck4QMTMueGhlegibZ 7xANL3PquethQ/G/xTBS2jEFju0Z2lTEMLqolGPple/OL0n9aT0thvPSd/tP98A4/GmV f+pQ== MIME-Version: 1.0 X-Received: by 10.60.78.227 with SMTP id e3mr2982477oex.5.1382551817449; Wed, 23 Oct 2013 11:10:17 -0700 (PDT) Sender: patrick.allaert@gmail.com Received: by 10.76.133.41 with HTTP; Wed, 23 Oct 2013 11:10:17 -0700 (PDT) In-Reply-To: References: Date: Wed, 23 Oct 2013 20:10:17 +0200 X-Google-Sender-Auth: 6TLaWRWI-dSlO01Y9VZVKgfwX-U Message-ID: To: Dmitry Stogov Cc: Julien Pauli , David Soria Parra , Stas Malyshev , PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Improved performance of array_maerge() and func_get_args() From: patrickallaert@php.net (Patrick ALLAERT) 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