Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46696 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 91755 invoked from network); 13 Jan 2010 16:09:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Jan 2010 16:09:34 -0000 Authentication-Results: pb1.pair.com smtp.mail=tstarling@wikimedia.org; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=tstarling@wikimedia.org; sender-id=unknown Received-SPF: error (pb1.pair.com: domain wikimedia.org from 66.111.4.25 cause and error) X-PHP-List-Original-Sender: tstarling@wikimedia.org X-Host-Fingerprint: 66.111.4.25 out1.smtp.messagingengine.com Received: from [66.111.4.25] ([66.111.4.25:51415] helo=out1.smtp.messagingengine.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DF/E7-00773-C30FD4B4 for ; Wed, 13 Jan 2010 11:09:33 -0500 Received: from compute1.internal (compute1.internal [10.202.2.41]) by gateway1.messagingengine.com (Postfix) with ESMTP id 41BD6CBF64; Wed, 13 Jan 2010 11:09:06 -0500 (EST) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute1.internal (MEProxy); Wed, 13 Jan 2010 11:09:08 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=messagingengine.com; h=message-id:date:from:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; s=smtpout; bh=1ZMoKDttuK8KNcW7K4SKVgOynDs=; b=ZWehGrZyAKq3u+0oY2kaQw4lx1O9d92frYGNy1W2WocL2ujVw4C2nlwdrc3SjJL3lo9O0kdgkm/piQukKuhGkYbOg0O0n2G8cv1fvVhjc8Vj+34xGAoAeD40S8dQeJ0sMu4V7jSuaWYRJqZWkN8PM/q74kQGtypsLwTAGB/869A= X-Sasl-enc: W57CRSYalmdlQc29zRXlzf0UboFxzjvGNfcHjlR+zbhd 1263398943 Received: from [10.0.0.2] (CPE-124-176-96-118.lns3.ken.bigpond.net.au [124.176.96.118]) by mail.messagingengine.com (Postfix) with ESMTPSA id 4100C4AE436; Wed, 13 Jan 2010 11:09:02 -0500 (EST) Message-ID: <4B4DF01A.1080103@wikimedia.org> Date: Thu, 14 Jan 2010 03:08:58 +1100 User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: Graham Kelly CC: Dave Ingram , "mathieu.suen" , Sebastian Bergmann , internals@lists.php.net References: <4B4DABED.4060202@easyflirt.com> <4B4DBF40.5040801@easyflirt.com> <4B4DCFDA.6090206@dmi.me.uk> In-Reply-To: X-Enigmail-Version: 0.95.7 OpenPGP: id=BF976370 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] About optimization From: tstarling@wikimedia.org (Tim Starling) Graham Kelly wrote: > Overall though, more often than not PHP is not the bottleneck of your > program and thus optimization wont get you too much. In a lot of ways, PHP is already well-optimised. The hash tables are fast, the executor is decent, as executors for weakly-typed languages go. Many internal functions have quite reasonable C implementations. 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 not much less. A simple object (due to being based on the same inefficient data structure) may use a kilobyte or two. Despite the large amount of time I've spent optimising MediaWiki for memory usage, it still can't run reliably with memory_limit set less than about 80MB. That means you need a server with 500MB if you want to set MaxClients high enough to let a few people use it at the same time. So if it were my job to set priorities for PHP development, I'd spend less time thinking about folding constants and more time thinking about things like: * Objects that can optionally pack themselves into a class-dependent structure and unpack on demand * 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 That sort of thing. -- Tim Starling