Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94126 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37130 invoked from network); 19 Jun 2016 16:35:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jun 2016 16:35:59 -0000 Authentication-Results: pb1.pair.com header.from=aaron@trowski.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=aaron@trowski.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain trowski.com designates 199.38.81.6 as permitted sender) X-PHP-List-Original-Sender: aaron@trowski.com X-Host-Fingerprint: 199.38.81.6 mercury.negativeion.net Received: from [199.38.81.6] ([199.38.81.6:63069] helo=mercury.negativeion.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C9/3D-18862-DE9C6675 for ; Sun, 19 Jun 2016 12:35:57 -0400 Received: from localhost (localhost [127.0.0.1]) by mercury.negativeion.net (Postfix) with ESMTP id 9925B3B06C90; Sun, 19 Jun 2016 12:35:54 -0400 (EDT) X-Virus-Scanned: amavisd-new at negativeion.net Received: from mercury.negativeion.net ([127.0.0.1]) by localhost (mercury.negativeion.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BaSwBpyQFsp3; Sun, 19 Jun 2016 12:35:53 -0400 (EDT) Received: from [10.0.1.3] (unknown [173.225.150.231]) by mercury.negativeion.net (Postfix) with ESMTPSA id C4AD53B06C81; Sun, 19 Jun 2016 12:35:53 -0400 (EDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) In-Reply-To: Date: Sun, 19 Jun 2016 11:35:50 -0500 Cc: "internals@lists.php.net" , Dmitry Stogov Content-Transfer-Encoding: quoted-printable Message-ID: <549528A0-E6D0-4413-B8C3-CD3C37685E53@trowski.com> References: <8284FE1F-70EE-4DB6-A945-0C57A4C99DCC@trowski.com> <16ef864f-8378-1af3-ddfb-21dc583a4b4a@gmx.de> <35132CB5-6E11-477F-8AC6-4374A7434D43@trowski.com> To: Dan Ackroyd X-Mailer: Apple Mail (2.3124) Subject: Re: [PHP-DEV] [RFC] Iterable From: aaron@trowski.com (Aaron Piotrowski) > On Jun 18, 2016, at 6:11 PM, Dan Ackroyd = wrote: >=20 > Hi Aaron, >=20 >> does anyone have any further feedback on this proposal? >=20 > What is the performance impact of the RFC on the standard performance > benchmarks? >=20 > And can you comment on the performance of using iterable as a type for > parameters/return types, compared to normal classes? >=20 > cheers > Dan Hi Dan, Great questions! This RFC has litte to no impact to the standard performance benchmarks. = These benchmarks do not have functions with type declarations, so they = are largely unaffected by an of the code changed by this RFC. The largest impact is to functions with scalar parameter or return type = declarations. An extra integer comparison is performed during the = compilation step to check if the type declaration equals IS_ITERABLE. = [1] for parameter and [2] for return types. If a parameter is not a = class name and has a default argument, another integer compare is = performed [3]. The patch also performs an additional integer compare to IS_ITERABLE = when a type not directly matching the type declaration is provided and = the type declaration is a scalar type. This applies to both parameter = [4] and return type declarations [5]. User code using `iterable` would only be slightly slower than using = `array` or `Traversable`, as a few extra integer comparisons are made = and additional function call is made to verify the type matches one of = the two allowed types (see [4] and [5] again). However, the flexibility = provided by `iterable` is well worth this very small penalty. For = comparison, this overhead is far less than the `callable` pseudo-type as = the value is not examined, only the type. In my tests against type declarations using other interfaces such as = `Iterator` or `IteratorAggregate`, using `iterable` was about equal in = performance. [6] Overall in my opinion, the performance impact of this RFC is negligible. Dmitry, could you take a look at the patch and do some of your own = performance checks? Thanks! Aaron Piotrowski [1] = https://github.com/php/php-src/pull/1941/files#diff-9760ee109b1c5922071fac= 1e19d117dfR332 [2] = https://github.com/php/php-src/pull/1941/files#diff-9760ee109b1c5922071fac= 1e19d117dfR360 [3] = https://github.com/php/php-src/pull/1941/files#diff-3a8139128d4026ce0cb0c8= 6beba4e6b9R5082 [4] = https://github.com/php/php-src/pull/1941/files#diff-a5fb5fd8c4f7311c6d0788= 763e665daaR857 [5] = https://github.com/php/php-src/pull/1941/files#diff-a5fb5fd8c4f7311c6d0788= 763e665daaR1080 [6] https://gist.github.com/trowski/6f4b8b689228c7ba930fa658bb3c87f9