Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37219 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92353 invoked from network); 25 Apr 2008 15:34:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Apr 2008 15:34:07 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.162 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 212.25.124.162 mail.zend.com Linux 2.5 (sometimes 2.4) (4) Received: from [212.25.124.162] ([212.25.124.162:16903] helo=mail.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 18/5D-18287-8E9F1184 for ; Fri, 25 Apr 2008 11:34:05 -0400 Received: (qmail 31646 invoked from network); 25 Apr 2008 15:33:54 -0000 Received: from mail.zend.net (HELO ws.home) (10.1.1.1) by cvs.zend.com with SMTP; 25 Apr 2008 15:33:54 -0000 Message-ID: <4811F9E1.2010900@zend.com> Date: Fri, 25 Apr 2008 19:33:53 +0400 User-Agent: Thunderbird 2.0.0.12 (X11/20080226) MIME-Version: 1.0 To: Matt Wilmas CC: internals@lists.php.net, Stanislav Malyshev References: <014b01c8a6db$57d53ba0$0201a8c0@pc1> In-Reply-To: <014b01c8a6db$57d53ba0$0201a8c0@pc1> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [PATCH] More array filling optimizations From: dmitry@zend.com (Dmitry Stogov) Hi Matt, I like the idea (especially ZEND_INIT_ARRAY optimization) and from the first look patch seems proper. I'll need to look into it more careful before commit (probably on next week). Thanks. Dmitry. Matt Wilmas wrote: > Hi all, > > Expanding on the idea of passing a size other than 0 to zend_hash_init(), > when possible, which was done awhile ago in a few areas (to save > resize/rehash operations), I finally added an "array_init_size()" that can > be used instead of array_init(), likewise, when a size is known. As an > example to start, I updated these functions: > > array_*: change_key_case, chunk, combine, fill, fill_keys, flip, keys > (without $search_value), map, rand, reverse, slice, splice, unique (since it > copies all entries first), values; and also compact; func_get_args; > get_defined_vars; str_split; and a couple internal uses. > > Those were the simplest, most obvious cases I found. :-) I didn't test > every function, but for example, the array functions that don't do much work > I found to be ~10% faster (with more than 8 elements, otherwise no resizing > would be needed). If these changes are applied, more can be done where > possible, by others, or I can and send further patches, or update them > myself if I have CVS access... > > http://realplain.com/php/array_init_size.diff > http://realplain.com/php/array_init_size_5_3.diff > > I was playing with initializing scripts' array( ... ) constructs with the > correct size too, but wasn't sure about the changes or what the opinion > would be. Runtime creation is improved with >8 elements, though it adds a > bit of compile overhead. Anyway, separate patches for that: > > http://realplain.com/php/array_init_size_vm.diff > http://realplain.com/php/array_init_size_vm_5_3.diff > > > Thanks, > Matt > >