Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:59415 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 21860 invoked from network); 7 Apr 2012 14:59:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Apr 2012 14:59:35 -0000 Authentication-Results: pb1.pair.com header.from=luke@cywh.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=luke@cywh.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain cywh.com from 209.85.220.170 cause and error) X-PHP-List-Original-Sender: luke@cywh.com X-Host-Fingerprint: 209.85.220.170 mail-vx0-f170.google.com Received: from [209.85.220.170] ([209.85.220.170:65388] helo=mail-vx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AB/F6-23111-356508F4 for ; Sat, 07 Apr 2012 10:59:32 -0400 Received: by vcbfo14 with SMTP id fo14so1373214vcb.29 for ; Sat, 07 Apr 2012 07:59:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-type:x-gm-message-state; bh=xIr0NwhuscjlHj7kTAwo5qcvisQqiTsYZl6cB9ez7gE=; b=HRFcy67QBIJnuMih4H/HwdTmyXxaBdO3v02u3ZyOh53E7qbzO0A/NKrqtPqzMtdXBk Okj9jVIdffdAYQk1UChOUA7lji0SnrcC6uFaa4Kgj1yJEPOagjfQfxZ4New0mZn5+kCw 3dIljkAxw5z24Upx13c2imGYrfBhzrMRbfQXXGUJ7XMZEgTcDuDAhUBCJNIx7fyxMSUl RoeTXu44bTlEO6SDq3so1Tw7qMwdS2Y/U+XrIpRSHwbTIaAyBLaECdS9bs0Ed2AZf0qg TBlGKvm209m+uiy8v/LiDcBxTkN5nzSnP5yJRKTIrnuQoG5/0wSoUBjfa2vHWHKJ4qge XxqA== Received: by 10.220.151.133 with SMTP id c5mr786560vcw.1.1333810769502; Sat, 07 Apr 2012 07:59:29 -0700 (PDT) Mime-Version: 1.0 (1.0) References: <2082600.13123.1333758215113.JavaMail.mobile-sync@iaje9> <7714055974799768995@unknownmsgid> In-Reply-To: Date: Sat, 7 Apr 2012 07:59:26 -0700 Message-ID: <3194191830858287831@unknownmsgid> To: Pierre Joye Cc: =?ISO-8859-1?Q?Johannes_Schl=FCter?= , "internals@lists.php.net" Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQkt7DQkECIyR/gPxzdgu4btJYEib4jvC7gaf8J/6JhlLErVxbhXHieUlbBlpY7V00iFyfED Subject: Re: [PHP-DEV] Persistent zvals From: luke@cywh.com (Luke Scott) On Apr 7, 2012, at 5:22 AM, Pierre Joye wrote: > hi, > > 2012/4/7 Luke Scott : > >> It would be ideal of you could initialize a bunch of objects once and >> carry them over to the next request. No serialization, no copying. A >> lot of framework objects would benefit from this. > > The expensive parts here are not the object creation on its own but to > get the data they contain (external, calculation, etc.). With heavy objects, yes. But when you have hundreds of objects? The unseralization process in no more efficient than creating the objects directly. > That's why we have magic methods like __sleep and __wakeup. Making > objects or values persistent across requests is not possible or very > hard. It is way cleaner to create them on each request and save the > expensive computation or data fetching time (see doctrine for example) > instead of trying to figure out tricks to get rid of the references > and all other ways to mess up a zval between requests. It depends. It's only cheaper when you have heavy objects. How do other platforms with a persistent application instance handle this? I don't believe references are really that big of an issue. You still have scope and refcounts. The difference is now refcounts are ignored and everything is thrown away at the end of the request vs refcounts being observed and memory persisting past the request. I think the bigger issues are how to persist the memory without fragmentation. Stanislav talked about that (although those comments didn't make it to the list - my fault for not hitting reply all). > The serialization method can be optimized easily, igbinary for example > can help to speed up this process. Optimized, sure. But you can only go so far. You still have the cost of recreating those objects. The only way to make it truly zero is by not recreating them. igbinary helps. But what about a large binary tree? The only way to efficiently keep this in memory (currently) is to write a C/C++ extension that persists the memory as a resource. But this takes much more time and effort than writing it in PHP. > It is also important to keep in mind that PHP is not designed to have > persitant user land values and won't be. > There are very good tools to > store these data, like memcached, couchbase, redis and co for the > distributed ones, apc and other for local caches (even like mysqlnd_cc > for caching mysql results :). And these are great solutions to a different set of problems. But they aren't the token solution to every problem. With a lot of large frameworks you spend more time initializing the framework than the request itself (besides querying external resources like MySQL). I think the most frustrating thing for me is knowing this isn't an issue with web applications written in Java, which has an always on application instance that handles requests. I've always viewed java as bloated and slow... But with recent developments of Java being jit compiled to native code, these issues are starting to go away. I have invested 10 years into PHP. Id rather stick with what I know. But it scares me that many enterprises in our sector chose Java over PHP. Luke > > Cheers, > -- > Pierre > > @pierrejoye | http://blog.thepimp.net | http://www.libgd.org