Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113507 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 91434 invoked from network); 13 Mar 2021 22:04:54 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 13 Mar 2021 22:04:54 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8677C1804B4 for ; Sat, 13 Mar 2021 13:57:58 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12olkn2072.outbound.protection.outlook.com [40.92.21.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 13 Mar 2021 13:57:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=glCuF9XTN9vwfVM6lHI5OzAbsRNYqsWEuFjR6PsFr26qiO3sqBwTKsOU2RVpBf8Kidq1DXgmRU1UFyCrNzdfDTQ9LYrs8LVIga+/l3zPfJZuKTjNsihaClLPBNHzdUDksYLKcsquqjpswx7kv+KRtA6CzjJRms+TufT5El3L/lAREUF9jl/DBXC6FJznwCnnQy3Gfl12NNtni8Ri0VmWSQBPRLy/doqAm0W7af6vfV8qsIYgYwWhUM9ZR3/EfClpK8UkGWVoKheAaJalMeZE9fZsQxBoEKbIwZlZ1XJvd2wG8r1gadUmAJheIiAWINRjG9t1DBSwPeS0TEWTFRzX7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JEq/6WpH6lmq9slUb3ntfmGk3bl64MDKBfZSUugkJD0=; b=nvWaYhow6HJBLxNLdtBcTewrHY0TQtwQAWr22C3yN9fLEGgahzXqb8wqoofEEmP0ABhh8eGAPqOzNUN+Wc2ssU/SPg0f4CfSnvgNHYacvaq5C8IeQeruYOwAz7PF1m9bE0KKwFq/Ez9eElBAydG1wnUgmIW0RsXmG9d/19TxEUuvwJO/TrqYbzVkIfvwH08FSL+4THro2QONk2XZ+mxMLA42CyWUg4dVMLjxCSu36KtElDU5blRjBZGo6cyz2GTT62tF1Vhde2eumgp5eUXMd7++xDVStrLfL280NXlPIF/ntdD65q3N1H//2A6t4BLk44P8iTfS1do1UFkn57Y6vw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JEq/6WpH6lmq9slUb3ntfmGk3bl64MDKBfZSUugkJD0=; b=ikKPOpWj94kLsgao9HkRQykd6MnGFtSJxMe9+SLmQ3b3pNnF5vJ+BxhHeGakffxEoWRW14aB6fYfAuIbtYKs+UbX0JK49X+2iGKWmmeq0Al7qTQGMtLWsh1PjwQRuonF/pOQDDBhhXNQf0my3beLXKleFY1hPCC49UppGLqE6IT8WmnSYWYoAqD9cAKPjgDj2X2wGzql0jRvcxzVAxO8Y2Cuuei4UBAe9v3nYC0uBEgoMp7bYtSC5WWYD25R+yfe7C6AE4Wa6PPmaY8fcVrzX1VIu2GX+bj7OuvrtmU9nUuARDgmvFw656Mdcy4oLJkz3B/3xAynhRHotRsElufsUA== Received: from MW2NAM12FT044.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc65::4c) by MW2NAM12HT204.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc65::250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.9; Sat, 13 Mar 2021 21:57:55 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:fc65::4a) by MW2NAM12FT044.mail.protection.outlook.com (2a01:111:e400:fc65::247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3955.9 via Frontend Transport; Sat, 13 Mar 2021 21:57:55 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::9c7c:2273:6416:6a0b]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::9c7c:2273:6416:6a0b%6]) with mapi id 15.20.3933.031; Sat, 13 Mar 2021 21:57:55 +0000 To: "internals@lists.php.net" Thread-Topic: [PHP-DEV] Storing the lcname of symbols Thread-Index: AQHXE3ZQtmV+o4XnfkmGnmiMAX+vqap6SZyAgAguzr4= Date: Sat, 13 Mar 2021 21:57:55 +0000 Message-ID: References: , In-Reply-To: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:34F961FAD5D0187E41E9940036D3CB861F01E57D00978273F07E7487450F0F9C;UpperCasedChecksum:F8235385E6B053D38591C48F1FCD5025BD78FD302766F5BB81FC184D545334A5;SizeAsReceived:7093;Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [UZFH+jNLQ0gO5pmUmEUlKIaPg0nrcaXTFkPrrfv2dyfh39UVSoSAlmIycmFbLYxf] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: abccb58e-25c2-46f8-9d5e-08d8e66b0ed6 x-ms-traffictypediagnostic: MW2NAM12HT204: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: lCxmFU+NRQ/84T9VfyV/t9cpfE54xHBLCRIRYxAFuybNmOC0tQYZ6xQYGefDFJCfE9FcbqeR8wPB5C0dTywCPIyERbQmtMkxFDxZdce1qiTgRO11vdU8EraExi4/j9CiM6YYPAyT4L1y4/p9aF0a8XSbB5Nx8qMjT9H0CSq5m5JnnzlIicAxuQxsQy84XBExMHa/s8cQTb0NF8jFLGkIxhdcOn24x66LcfHyg9e5Y0CR+YsXng5SMKK/J8oS0rFZbTf0gJJ8RMz1xlYZnzsTaiVGjFjU/pFhDikKT1Dy+2zepCBjm/ybTcB2IP7PDL2lUeEpnHoMaWer3YQxgEGTEXZfSzQlSIuLOJjR4Egzjo0qqsW5ELqh6278f5rQ/yKSDpN6wxHsWSMFJb4w1ZS8NgQFdq9eW8TPN0UD66vfgoIXD7qV5WdN5/zNrcHcKT9G x-ms-exchange-antispam-messagedata: /ZrAuvU6yMMy8ibxvMLhaakZMhz4eRPv5mEFTQ3XzFXx2G/6YoGszndl+a9sX86+Sov6ZhdEroYB4UEZcRHV67RbPRc2fhOJ4Ip9HkMikYJQmqWy9v12XWx57dXTVL0tJL2mRHX0EhIbC3pTBBT7mdzOHtCAvanUkOrQihtmIhTaBBgpxDYRC3epGVHsawC8CXkvVktlcyFQ6tfx73kMjw== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: MW2NAM12FT044.eop-nam12.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: abccb58e-25c2-46f8-9d5e-08d8e66b0ed6 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Mar 2021 21:57:55.6710 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2NAM12HT204 Subject: Re: [PHP-DEV] Storing the lcname of symbols From: tysonandre775@hotmail.com (tyson andre) Hi Levi Morrison,=0A= =0A= > > Hello!=0A= > >=0A= > > Most of PHP's symbols are case insensitive. This means extensions that= =0A= > > need to do things with function and method names end up lowercasing=0A= > > and hashing the lowercased names, often having to do more memory=0A= > > allocations too. Since case insensitive symbols is language dictated=0A= > > behavior, it makes sense to expose the correctly cased symbols to=0A= > > extensions. In PHP 8.0 (and possibly older, I did not check), the=0A= > > engine is already interning the lowercased name of user defined=0A= > > functions; it's just not made available to extensions.=0A= > >=0A= > > In my ideal world, we'd actually switch all symbols to be case=0A= > > sensitive. However, that won't be happening for PHP 8 due to BC.=0A= > >=0A= > > So, instead, I propose adding an `.lcname` member (or some other name= =0A= > > indicating it's been normalized to the preferred PHP case) to at least= =0A= > > zend_op_array and zend_class_entry, but preferably for internal=0A= > > functions too. Note that many internal functions will already be=0A= > > lowercase, so the data can be shared.=0A= > >=0A= > > I could make this change in the main engine, but I strongly suspect it= =0A= > > will not play correctly with opcache.=0A= > >=0A= > > --=0A= > > PHP Internals - PHP Runtime Development Mailing List=0A= > > To unsubscribe, visit: https://www.php.net/unsub.php=0A= > =0A= > I just realized I didn't ask any specific questions. Oops:=0A= > =0A= > =A01. Can anyone think of issues except increased memory due to=0A= > increasing the size of the struct? Since the strings were previously=0A= > interned, I don't think the strings themselves will have much effect=0A= > on memory usage (but we can measure this).=0A= > =A02. Anyone else who thinks this would be useful?=0A= =0A= I don't have a personal use case for this and no common operations come to = mind but could be persuaded.=0A= The lack of examples or might be why there's been no response.=0A= I assume the overhead is probably negligible for classes, and larger for fu= nctions.=0A= What fields of zend_op_array did you mean?=0A= =0A= What parts of the engine or extensions would use the lowercase string? =0A= I see a few places it's used for compilation in php-src itself but nothing = that seems performance critical.=0A= =0A= What are examples of functionality/functions of extensions that you expect = would see a performance improvement?=0A= Why would they need to convert the strings to lowercase rather than use the= casing of the declaration=0A= (e.g. using "memcached" instead of "Memcached" in "class Memcached{...}")= =0A= =0A= E.g. if something had already looked up the `zend_class_entry *ce` for a cl= ass name, than `ce->name`=0A= would be a string (and a unique pointer) such as "Memcached" that uniquely = identifies that class's name=0A= (unless the code is unexpectedly redeployed later with different casing)=0A= =0A= - They're still case sensitive in some ways, e.g. the composer autoloader i= s case sensitive=0A= - Changing case should be rare=0A= =0A= Regards,=0A= Tyson=0A=