Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46712 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79943 invoked from network); 13 Jan 2010 23:48:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Jan 2010 23:48:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=stas@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=stas@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 63.205.162.117 as permitted sender) X-PHP-List-Original-Sender: stas@zend.com X-Host-Fingerprint: 63.205.162.117 us-mr1.zend.com Received: from [63.205.162.117] ([63.205.162.117:33309] helo=us-mr1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B4/B9-00773-0CB5E4B4 for ; Wed, 13 Jan 2010 18:48:17 -0500 Received: from us-gw1.zend.com (us-ex1.zend.net [192.168.16.5]) by us-mr1.zend.com (Postfix) with ESMTP id C59E843C8A; Wed, 13 Jan 2010 08:54:28 -0800 (PST) Received: from [192.168.16.93] ([192.168.16.93]) by us-gw1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 13 Jan 2010 15:48:13 -0800 Message-ID: <4B4E5BBC.3080507@zend.com> Date: Wed, 13 Jan 2010 15:48:12 -0800 Organization: Zend Technologies User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.5) Gecko/20091204 Lightning/1.0b2pre Thunderbird/3.0 MIME-Version: 1.0 To: Tim Starling CC: Graham Kelly , Dave Ingram , "mathieu.suen" , Sebastian Bergmann , internals@lists.php.net References: <4B4DABED.4060202@easyflirt.com> <4B4DBF40.5040801@easyflirt.com> <4B4DCFDA.6090206@dmi.me.uk> <4B4DF01A.1080103@wikimedia.org> In-Reply-To: <4B4DF01A.1080103@wikimedia.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 13 Jan 2010 23:48:13.0537 (UTC) FILETIME=[DEB70D10:01CA94AA] Subject: Re: [PHP-DEV] About optimization From: stas@zend.com (Stanislav Malyshev) Hi! > Given this, sometimes it's easy to forget that PHP is pathologically > memory hungry, to the point of making simple tasks difficult or > impossible to perform in limited environments. It's the worst language > I've ever encountered in this respect. An array of small strings will > use on the order of 200 bytes per element. An array of integers will use HashTable uses 40 bytes, zval is 16 bytes, Bucket is 36 bytes, which means if you use integer indexes, the overhead is 72 bytes per value including memory block headers and alignments. It might be too much for you, in which case I'd go towards making an extension that creates an object storing strings more efficiently and implementing either get/set handlers or ArrayAccess (or both). This of course would be most useful if you access only small part of strings in each function/method. I do not see what could be removed from Bucket or zval without hurting the functionality. > not much less. A simple object (due to being based on the same > inefficient data structure) may use a kilobyte or two. Kilobyte looks like too much for a single simple object (unless we have different notions of simple). Could you describe what exactly makes up the kilobyte - what's in the object? > * Objects that can optionally pack themselves into a class-dependent > structure and unpack on demand Objects can do pretty much anything in Zend Engine now, provided you do some C :) For the engine, object is basically a pointer and an integer, the rest is changeable. Of course, on PHP level we need to have more, but that's because certain things just not doable on PHP level. Do you have some specific use case that would allow to reduce > * Exposing strongly-typed list and vector data structures to the user, > that don't have massive hashtable overheads > * An oparray format with less 64-bit pointers and more smallish integers Ah, you're on 64-bit... That explains why your memory requirements is larger :) But I'm not sure how the data op array needs can be stored without using pointers. -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com