Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:32045 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8631 invoked by uid 1010); 4 Sep 2007 18:35:25 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 8616 invoked from network); 4 Sep 2007 18:35:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Sep 2007 18:35:25 -0000 Authentication-Results: pb1.pair.com smtp.mail=nlopess@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=nlopess@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 212.55.154.23 as permitted sender) X-PHP-List-Original-Sender: nlopess@php.net X-Host-Fingerprint: 212.55.154.23 relay3.ptmail.sapo.pt Linux 2.4/2.6 Received: from [212.55.154.23] ([212.55.154.23:56860] helo=sapo.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AA/24-14196-B65ADD64 for ; Tue, 04 Sep 2007 14:35:24 -0400 Received: (qmail 28846 invoked from network); 4 Sep 2007 18:35:19 -0000 Received: from unknown (HELO http13) (10.134.35.198) by relay3 with SMTP; 4 Sep 2007 18:35:19 -0000 Received: (qmail 6923 invoked by uid 64140); 4 Sep 2007 18:35:17 -0000 Received: from bl7-48-52.dsl.telepac.pt (bl7-48-52.dsl.telepac.pt [85.240.48.52]) by w13.mail.sapo.pt (Horde MIME library) with HTTP; Tue, 04 Sep 2007 19:35:17 +0100 Message-ID: <20070904193517.i279eprj40ogkc0k@w13.mail.sapo.pt> Date: Tue, 04 Sep 2007 19:35:17 +0100 To: David Wang Cc: internals@lists.php.net, andi@php.net, dmitry@php.net References: <20070904162613.4qgfdddo7scw8o8w@w13.mail.sapo.pt> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; DelSp="Yes"; format="flowed" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable User-Agent: Internet Messaging Program (IMP) H3 (4.2-cvs) X-Originating-IP: 85.240.48.52 X-PTMail-Version: 3.1.5 Subject: Re: Re: [PHP-DEV] Patch for macros for tracking refcount and is_ref From: nlopess@php.net (Nuno Lopes) > Off the shelf garbage collectors such as BDW would be inappropriate > because we use some weird kinds of "pointers" (such as object handles) > stored in weird kinds of ways (such as a zend_hash object). I think it > would be pretty inefficient, since those implementations just scan the > stack, registers and heap and we're trying to do GC not for the PHP > interpreter, but for the code the PHP interpreter is running. surely it wouldn't be the top performance GC, but I think it worths a =20 try. And it doesn't seem difficult to use that GC (after your patch =20 specially). > For just > displaying page, there wouldn't be much memory used and that's all > freed at the end of a request anyway: all of that reference counting > overhead would just disappear. For larger scripts that use a lot of > memory, the only problem would be pause times but in most real life > cases, it seems the total time would be shorter than reference > counting. However, I'm not sure if that would be the case in PHP: > rummaging through objects scattered all over memory would result in a > lot of cache misses. The question is whether that is greater than all > the misses we're currently having just managing the refcount. exactly. for most PHP requests the GC wouldn't even run. The garbage =20 would be collected after the request, thus reducing the latency of the =20 request (for Gopal pleasure :) > However, answering that question would require implementing the thing, > and that honestly seems like it would be a bit of a nightmare. Roots > would include zvals linked to PHP variables, the stack of the running > PHP code, and the stack and heap of the PHP interpreter itself. It > would've been far easier if PHP had been designed from the ground up > to use some sane way of managing memory, but with the current > situation, with extensions depending on reference counting, it's > pretty difficult. implementing a GC from scratch is a difficult job, yes and hence my =20 idea to try an existenting GC. But if we look to the GCs used by e.g. =20 the Common Lisp implementations, we see that they have highly-tuned =20 and highly-performant GC implementations that take advantage of how =20 the internal structures are implemented. And I suspect Java does that, =20 too. Well, maybe we can find some crazy student next year to do it *hint* =20 :). Or maybe I get crazy too one of these days ;) (well I still have =20 to pick something to do for the master thesis..) Nuno