Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80043 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19514 invoked from network); 1 Jan 2015 13:23:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Jan 2015 13:23:33 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.169 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.212.169 mail-wi0-f169.google.com Received: from [209.85.212.169] ([209.85.212.169:42374] helo=mail-wi0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EF/78-60454-45A45A45 for ; Thu, 01 Jan 2015 08:23:32 -0500 Received: by mail-wi0-f169.google.com with SMTP id r20so28075869wiv.2 for ; Thu, 01 Jan 2015 05:23:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=LuWlkZUQpmvCkpCkhnIFQJVIjx59u313z5RmBmQqVkY=; b=mQxdu1ZFGf6ELD+lj3K75VP6+zBSXi3CsNJnSYK/zTiSaM4cPsBXmNqzCD8Q260fms LUKIvPgQEYwK9uxr1oN06QYF5du0qu7dreczdVzS54/J8mpkPtBvKKty+p7qCNTO6Nbq FMSnPNzgZuBCaSX1kk01iFIFdaGV2jH4Hf/u7T7nRryPWxdFwNgMl7jmdxL/+cSSEi9h idJ2X/6EJWgc0jYAgI62yj/p+aEvMAY6ZsbMab8qx/G3sxslKd1dWBqL1qfuT0RtFmdn 4o/f6+dIofkwIhhojxdH6PX8w/Hzq/jJITGHl87if4f2PTAom6/ZlwNMfUrbg7Pku206 ME/A== MIME-Version: 1.0 X-Received: by 10.180.76.144 with SMTP id k16mr122262902wiw.3.1420118607851; Thu, 01 Jan 2015 05:23:27 -0800 (PST) Received: by 10.27.10.196 with HTTP; Thu, 1 Jan 2015 05:23:27 -0800 (PST) In-Reply-To: References: Date: Thu, 1 Jan 2015 14:23:27 +0100 Message-ID: To: Dmitry Stogov Cc: Xinchen Hui , PHP Internals Content-Type: multipart/alternative; boundary=f46d0437494128f484050b9721ff Subject: Re: Merge HashTable and zend_array into a single data structure. From: nikita.ppv@gmail.com (Nikita Popov) --f46d0437494128f484050b9721ff Content-Type: text/plain; charset=UTF-8 On Wed, Dec 31, 2014 at 11:19 AM, Dmitry Stogov wrote: > Hi, > > Please take a look into the patch > > https://github.com/php/php-src/pull/970/files > > This real changes are in zend_types.h, the rest is renaming that in most > cases makes code cleaner. > > zend_array didn't change its binary representation, but now it's not > possible to get a pointer to embedded HashTable. The same zend_array shoukd > be used instead. > > Each HashTable got an extra 64-bit zend_refcounted header. This leads to > some increase in memory consumption. > In your patch zend_hash_init (and zend_hash_destroy as well) ignores the refcounted header. So currently you wouldn't be able to use just any HashTable* in a refcounted way (e.g. do an object->array cast by adding a ref to the properties HT and sticking it in a zval). You can only do the reverse, i.e. use a no longer used refcounted array somewhere else (like the way properties are assigned in pdo/... now). What's the plan about this? Is this intentional or will the hash API start managing the refcount as well (like strings already do)? > The performance is slightly increased (may be measured with callgrind). > > The patch beaks one test (tests/lang/foreachLoopObjects.006.phpt), but > actually it just disclose a problem that we have anyway. > > The patch should be a base for the future optimizations. e.g. removing > HashTable->arData and/or HashTable->arHash and allocating them together > with zend_array; introducing EG(empty_array) etc. > Could you elaborate on the first part? How is it possible to alloc arData/arHash together with zend_array? (Or rather, if you do that, how can you change the size later?) Nikita --f46d0437494128f484050b9721ff--