Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92089 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30145 invoked from network); 5 Apr 2016 09:04:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Apr 2016 09:04:35 -0000 Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.113.146.227 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.113.146.227 xdebug.org Received: from [82.113.146.227] ([82.113.146.227:52628] helo=xdebug.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 01/60-27948-0AF73075 for ; Tue, 05 Apr 2016 05:04:32 -0400 Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id 9387210C010; Tue, 5 Apr 2016 10:04:28 +0100 (BST) Date: Tue, 5 Apr 2016 10:04:28 +0100 (BST) X-X-Sender: derick@whisky.home.derickrethans.nl To: Dmitry Stogov cc: Nikita Popov , Bob Weinand , Xinchen Hui , Eran Ifrah , internals In-Reply-To: Message-ID: References: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Subject: Re: [PHP-DEV] RETURN micro optimization From: derick@php.net (Derick Rethans) On Tue, 5 Apr 2016, Dmitry Stogov wrote: > I propose a micro optimization for RETURN statement. > > Currently "return $x" increments reference counter of $x, then in > zend_leave_helper() we perform zval_ptr_dtor() on the same $x. > > The patch sets the original value of $x to null in first place, so > zval_ptr_dtor() is not going to be called. > > https://gist.github.com/dstogov/36f68b206242a39691ac539c2fc85d40 > > the performance impact is invisible (0.1% less instruction retired on > Wordpress). > > It breaks sapi/phpdbg/tests/breakpoints_005.phpt, but this is probably > not a big deal. > > BTW: this change may affect debuggers in some other way. I'd like to know why this breaks before saying something. It'd be a PITA if this micro optimisation wouldn't actually do a lot performance wise, but makes some debugging not possible. cheers, Derick