Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69254 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88603 invoked from network); 21 Sep 2013 19:45:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Sep 2013 19:45:28 -0000 Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain schlueters.de from 217.114.215.10 cause and error) X-PHP-List-Original-Sender: johannes@schlueters.de X-Host-Fingerprint: 217.114.215.10 mail.experimentalworks.net Received: from [217.114.215.10] ([217.114.215.10:43554] helo=mail.experimentalworks.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DD/10-21372-657FD325 for ; Sat, 21 Sep 2013 15:45:27 -0400 Received: from [10.158.121.109] (unknown [148.87.41.130]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: johannes@schlueters.de) by mail.experimentalworks.net (Postfix) with ESMTPSA id C8D323FF34; Sat, 21 Sep 2013 21:45:30 +0200 (CEST) To: ruben Cc: internals@lists.php.net In-Reply-To: References: <17.B1.31578.06A3C325@pb1.pair.com> <92.22.31578.33D3C325@pb1.pair.com> Content-Type: text/plain; charset="UTF-8" Date: Sat, 21 Sep 2013 21:45:04 +0200 Message-ID: <1379792704.3085.9.camel@guybrush> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: Performance update involving zval containers. Why not possible? From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) On Fri, 2013-09-20 at 17:01 +0200, ruben wrote: > >> I found out some cases where I think that some Variable Containers > >> copies could be skipped, thus saving memory and improving performance > >> relying in the copy-on-write principle. I wrote a PDF trying to explain > >> what I mean. It is not written in a very techy language, because I am > >> just new and don't know too much about the internals, but I hope you can > >> understand it and post your comments. > Sorry, here it is: > https://www.dropbox.com/s/wxdc99miw82zje9/PHP_references.pdf Yes, in this simplified version there might be a way to figure this out by doing special handling in the return handler (basically putting the returned variable aside, do the cleanup and then see whether the separation is still needed. In most reference cases you will have other immediate calls and operations in between which change the picture. The general suggestion is: Don't use references, then the copy-on-write can work in the most efficient way and really copy only when needed. I've collected some thoughts about that on http://schlueters.de/blog/archives/125-Do-not-use-PHP-references.html Getting code with references right is hard and in 99% of the cases (exceptions are in the area of circular graphs or algorithms working on graphs ...while even there often using objects is better) other approaches lead to faster and more maintainable code. johannes