Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105766 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 21485 invoked from network); 20 May 2019 23:23:08 -0000 Received: from unknown (HELO NAM04-SN1-obe.outbound.protection.outlook.com) (40.92.11.31) by pb1.pair.com with SMTP; 20 May 2019 23:23:08 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bWklA+g+TsX1MCwAPeTW0Ths6Zl+pMZdSbkptnCDcfs=; b=A3/6J7LMven3itgrWtN6S7XyxVX7xE9TsvCywjQOyRpCfFEmb9y2989jOxEP0PI/I+SbCz1T+xmsh62jeOuy5N3oFB+7vEuv1r/oCYQ+MehvYkzWXsrfS6jRindxXyXiJeTRd53FrjM4CDqcFizb3T2IgEn8r9B2jCCsF6A2SDxubPe4U+DtR15U3ZS5Jc0b7JYjn3mzfbNdOTbfoW3b2bRYPtOdsF6dVwsq43ruFVoB2cGa+JeAWDqArwhGm8rxCmWFvQce9SjDQtKPLTJh20EwEVwY2Y1DVQocZz/SK1NxJ1PI/JFQTecESuRFhdkQKQ3FkxfeOzlyTgXKUj8Odg== Received: from SN1NAM04FT037.eop-NAM04.prod.protection.outlook.com (10.152.88.56) by SN1NAM04HT153.eop-NAM04.prod.protection.outlook.com (10.152.89.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1900.16; Mon, 20 May 2019 20:30:21 +0000 Received: from DM5PR06MB2857.namprd06.prod.outlook.com (10.152.88.60) by SN1NAM04FT037.mail.protection.outlook.com (10.152.88.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1900.16 via Frontend Transport; Mon, 20 May 2019 20:30:21 +0000 Received: from DM5PR06MB2857.namprd06.prod.outlook.com ([fe80::8c9a:8f50:c23:76a5]) by DM5PR06MB2857.namprd06.prod.outlook.com ([fe80::8c9a:8f50:c23:76a5%5]) with mapi id 15.20.1900.020; Mon, 20 May 2019 20:30:21 +0000 To: Gabriel O , Marco Pivetta CC: PHP internals Thread-Topic: [PHP-DEV] High performance function autoloading Thread-Index: AQHVDy+ySrd8q1/GuEiFhoiHIw5ZMaZ0TZWAgAABNxaAABl9gIAAA/j2 Date: Mon, 20 May 2019 20:30:21 +0000 Message-ID: References: <16ad66607a0.27c1.08be835b7d1a2c2edb4c4286afe1a236@gmail.com> , In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:D88C2849DB649220D0E909D117C59054C9F9BD373F8C92136DBD99E621317737;UpperCasedChecksum:5129C79BD34D575C91B5205004C36D95E53929B1B7B3D433280DAB15E8D61994;SizeAsReceived:7022;Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [JI7IsVuuxWdYXT5AtsLKbGvfiyl+iXAY] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(5050001)(7020095)(20181119110)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031323274)(2017031324274)(2017031322404)(1601125500)(1603101475)(1701031045);SRVR:SN1NAM04HT153; x-ms-traffictypediagnostic: SN1NAM04HT153: x-ms-exchange-purlcount: 2 x-microsoft-antispam-message-info: Mh242OMOKPPHbc+BzIwEilZ8mQ+kqg+/y6ctvo1lOZCpJK8mhPYrGRamqq3nAcW6JHWTDF0TfQH5IAYTb6288jduecC/WuMVPjzFdztQ75AHXjKSsxe6Hxi8GwcfIboPKMoCHyGzDtdD6lIRBy3xc4cxM2YbQgxyQRZJnc1/DL+Z9jLMCQmiDj+lpGLeVHZ7 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: aefe1910-872d-4780-59a8-08d6dd61fafa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 May 2019 20:30:21.1260 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1NAM04HT153 Subject: Re: [PHP-DEV] High performance function autoloading From: theodorejb@outlook.com (Theodore Brown) On Mon, May 20, 2019 at 2:36 PM Gabriel O wrote:=0A= =0A= > > Can you clarify? I'm not sure what performance improvement trick you=0A= > > are referring to, or what you mean by "importing all functions". Are=0A= > > you saying it's a misconception that triggering an autoloader on=0A= > > unqualified function calls in a namespace will slow down performance?= =0A= > > As I understand it, this is the roadblock for function autoloading.=0A= > =0A= > Yes, this is misconception. Namespace resolutions are cached. First=0A= > fixer tool bringing support for this was correct: PHP-CS-Fixer auto=0A= > imports only optimized functions for this very same reason.=0A= =0A= I'm confused, since this doesn't match what I've read elsewhere. For=0A= example, Nikita wrote the following last time function autoloading was=0A= discussed: [1]=0A= =0A= > Calling the autoloader if a global function with the name exists will=0A= > totally kill performance. This means that every call to strpos() or=0A= > any of the other functions in the PHP standard library will have to=0A= > go through the autoloader first, unless people use fully qualified=0A= > names (which, currently, they don't). This is completely out of the=0A= > question.=0A= =0A= In the same thread, it was suggested that a cache could be used=0A= to avoid repeatedly triggering the autoloader, but concerns were=0A= also pointed out with this: [2]=0A= =0A= > > Of course calling e.g. strpos() should not trigger the auto-loader=0A= > > repeatedly - can we cache the information that the auto-loader was=0A= > > attempted once during the current script execution? so that e.g.=0A= > > only the first call to strpos() triggers the auto-loader?=0A= > =0A= > I think triggering it even once for every internal function in the=0A= > code may be too much.=0A= > =0A= > > I suppose it would still happen once for every namespace from which=0A= > > strpos() gets called, so maybe this optimization doesn't help much.=0A= > =0A= > Exactly. Also, caching stuff assumes static environment. What if it=0A= > changes, e.g. autoloader gets different configuration?=0A= =0A= This is why I suggested the alternative of by default falling back=0A= to the global namespace for unqualified functions before triggering=0A= the autoloader, and allowing this fallback to be disabled for the rare=0A= case where functions in a namespace are spread across files and need=0A= to override a global function.=0A= =0A= I don't think this proposal changes anything related to function=0A= mocking. As you pointed out, libraries can already prevent mocking=0A= by importing or qualifying global function calls.=0A= =0A= Sincerely,=0A= Theodore=0A= =0A= [1]: https://externals.io/message/94895#94897=0A= [2]: https://externals.io/message/94895#94956=