Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:59388 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50680 invoked from network); 7 Apr 2012 03:33:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Apr 2012 03:33:24 -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:63554] helo=mail-vx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 18/CF-57786-385BF7F4 for ; Fri, 06 Apr 2012 23:33:23 -0400 Received: by vcbfo14 with SMTP id fo14so1216933vcb.29 for ; Fri, 06 Apr 2012 20:33:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=references:from:in-reply-to:mime-version:date:message-id:subject:to :cc:content-type:content-transfer-encoding:x-gm-message-state; bh=8nMHup3Jtv6eP/vV/SDT3UGRC3McVbOqDo2BGHDji/A=; b=DZ3j3wkSuyp+EM60ISkodMqdAJHPjoEdek+KlOpeW95Bp80ib1rnm33OxDe0u26JjU 1INtdOAvH5fu4zJW2aJcsBKdvVDIJJXZMrRqNXH9boTkGkNQTvIBnOzyttbdW2ZV5XHw MmvO+7kV7o8d3nWRGT23clmW9Q2OwVZtR5gGDX0X++yqReoN7E5D2+Uek8cFh3eSZ/BY 28AifVRPL3N4CtA5eKQjqcEexMQT8LFoU38mbsjKSCTUe+ac5ioBRCPSMsfbGtN6SECI LJmPbo4/ZdnUljM8jLRQkKRJfvglQ+e1cqat6+Lzm5BjssyRQyQf1woTHByq7xlzend5 Ow5Q== Received: by 10.220.141.84 with SMTP id l20mr106597vcu.31.1333769600436; Fri, 06 Apr 2012 20:33:20 -0700 (PDT) References: <2082600.13123.1333758215113.JavaMail.mobile-sync@iaje9> In-Reply-To: <2082600.13123.1333758215113.JavaMail.mobile-sync@iaje9> Mime-Version: 1.0 (1.0) Date: Fri, 6 Apr 2012 20:33:17 -0700 Message-ID: <7714055974799768995@unknownmsgid> To: =?ISO-8859-1?Q?Johannes_Schl=FCter?= Cc: "internals@lists.php.net" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQmj+e9Nu0a8WL4N0s/Cag9bJpEa4zwtrZNa7eUqkEOxqOGRPWtRgewj2UEJtUMkrA2cArR/ Subject: Re: [PHP-DEV] Persistent zvals From: luke@cywh.com (Luke Scott) On Apr 6, 2012, at 5:23 PM, "Johannes Schl=FCter" = wrote: > Hi, > > On Fri, 2012-04-06 at 16:46 -0700, Luke Scott wrote: >> >> >> From what I've gathered thus far, it is impossible to do without >> copying the non-persistent memory into persistent memory, and then >> back again. I'm assuming this is because all the memory associated >> with PHP variables use emalloc, which places it onto a stack that is >> disposed of at the end of the request. >> >> So there seems to only be two ways to do this: >> >> 1 - Copy non-persistent memory into persistent memory (and back) using >> a deep copy. Probably not very efficient. May not be much better than >> serialization. > > Yes, see apc_store() and friends to see all the small parts needed to > copy it as properly as possible. While this still won't work for all > cases (resources, internal classes, ..) but well, this might be what > you're looking for in a ready state ;-) Apc serializes the data. Unless the data is a cache or session information there is almost no difference between unseralizing a bunch of objects verses and initializing the objects in code. 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. > >> 2 - Modify the Zend engine to flag objects/zvals as persistent so they >> aren=B9t thrown away until the process ends. > > Which is a major undertaking, taking copy-on-write and friends into > account. As in a case like > > mark_persistent($persistent); > $persistent['some key'] =3D function_returning_lots_of_data(); > > would suddenly require to create a copy of all the data. Such things can > quickly cost more than recreating the structures more frequently ... When having to copy data, yes thing yet messy very quickly. But if there were a persistent flag on the zval the new zval would have the persistent flag. The old one would be discarded when it's reference count reached zero. Right now everything is thrown out at the end of the request because it's created with emalloc, regardless of the recount. With a persistent flag (1 or 0) and a recount of 1 or greater it wouldn't be until the end of the process. Easier said than done - for sure. > > johannes > >