Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120348 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 29963 invoked from network); 18 May 2023 19:05:35 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 May 2023 19:05:35 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D8E85180503 for ; Thu, 18 May 2023 12:05:33 -0700 (PDT) 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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GUARANTEED_100_PERCENT, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS29838 64.147.123.0/24 X-Spam-Virus: No X-Envelope-From: Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 18 May 2023 12:05:28 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 382B932000D9 for ; Thu, 18 May 2023 15:05:27 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute4.internal (MEProxy); Thu, 18 May 2023 15:05:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-type:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1684436726; x= 1684523126; bh=rJZJOgLeIAftkGbYAKtcWecFCf0VNc5ghya7i9xjAow=; b=V aikO6VaU8vSfS8J74hfYv0vnv+fCsecZ4KQR/HU58rlWTsbG0nxg6WU0LxqbqRcr 31a9M9G6nwiZRta/Z8c3xy1rfkTU2ohzoq23Cd3CLkONiDK06YKPZhTvVABH5+Dp stV8ZhW07BBiC3eHC8C2Bd0/Xwg7ab0SXyg53CFbUMXtltZjOQkkynjC8HmM7jYr oa8rf/zckOrdWdWjzDBusmDhyJe7tUPjynoAB4yJdoiYMuq8hUA1DzQTQgIZLW/x q3yagCIgtzoeygxSudwMllvcbg3tAMOA8q1peKKdMJUIpM+0zAYP86/4+hjPomk9 C9kTCrURIzLs59VF/7JWg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1684436726; x=1684523126; bh=rJZJOgLeIAftk GbYAKtcWecFCf0VNc5ghya7i9xjAow=; b=x5R9DUl/m8LnSjyQYDtkc0X0gSQdn SapRSqwqvqbGswJoQiCu5RZXCv67e4Y0rEK+FheIOs+rw/k3mt5hCAtb2sn98IAs x7o+SiEAbvw+A+1D9wWqIXlNz4aipbpGLJf62xixSzUS1O66LQXrkVQ1ux6ho8Hf QGHpBdf7dME3eyDQSRhCkfoTss+/7IOP1SeepSXJ6zDRquWKzMCTzV0/0yl8a+Yi oZyEB7qNvHIJ9aDapv2RV+ikXNSfEWXUvmfcHJmWXr93PuRrzlX/30tXHJP8xlAS LH4E1IHAuMPUSSW7sOCNC072IxQMhJscqz92OQeCGcOoA6s+Kh76OzWPg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeifedgudeffecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepgeelgfekudeivddvteffueejffdthfejieevhefg ffekudevkedtvdelvddvffefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 6A04F1700089; Thu, 18 May 2023 15:05:26 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-431-g1d6a3ebb56-fm-20230511.001-g1d6a3ebb Mime-Version: 1.0 Message-ID: <512db5c3-cd61-49bc-b800-79132d0dbf0f@app.fastmail.com> In-Reply-To: References: <000201d9897f$aa9f9fa0$ffdedee0$@roze.lv> Date: Thu, 18 May 2023 19:05:05 +0000 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] PHP Package for PHP From: larry@garfieldtech.com ("Larry Garfield") On Thu, May 18, 2023, at 5:34 PM, Rowan Tommins wrote: > I actually wonder if some things in core should be removed to encourage > userland replacements - ext/soap, for instance, and some of the data > structures in ext/spl. > > IMHO, the things that would benefit from being written in PHP then bundled > are things that are so low-level that it's hard to get them wrong; the > building blocks that the community will use to build things like Monolog > and Guzzle. Another related prior: There's been on and off discussion for some time about moving stdlib C functions into PHP, and relying on preloading and JIT to make them fast. So far that hasn't happened, mainly because when someone has tried it out (mainly Nikita), it turned out to not be as fast as the existing C versions. I think there's a couple of different categories of library-esque code that need to be considered: 1. Low-level tooling that pretty much has to be in C to work correctly. This is pretty well covered already. Examples here are things like ext/curl, ext/pdo, streams, reflection, etc. 2. Application level tooling that almost every app needs. Logging is the obvious example here. 3. Base functionality that is notably faster in C than PHP. Here I include things like array_map(), array_reduce(), strlen(), etc. Much of those could be done in user-space, but there's an appreciable performance benefit to them being native in C. The new Random extension, too, *could* have been implemented in user-space, but would have been vastly slower. 4. Base functionality that is not notably faster in C, but is still considered "basic table stakes" for the type system. iterator_to_array(), for instance, could absolutely be implemented in user space, and probably wouldn't be any slower, but it's such a basic part of working with iterables that it would be an incomplete product to not have it. I would put str_contains() in the same category; it offers no real benefit other than 100% guaranteed presence, but that's enough in some cases. 5. Functionality that is often used, but not always, and gets no significant benefit from being in C. Those boundaries are a bit squishy, of course, with lots of edge cases. Personally, I don't think category 2 should be in the stdlib. That might have made sense 20 years ago, but between Composer and PHP-FIG, I don't think the argument is that compelling. Similarly, category 5 is best left to user-space. Category 1, obviously, should at least be PECL, but often in php-src standard. The tricky questions relate to what qualifies as "base functionality" and "basic table stakes", as well as how much of a performance improvement is necessary to justify inclusion (categories 3 and 4). There's also questions of historical precedent, but PHP's historical precedent is a total mess in most cases so that's not as strong an argument. :-) As an example, ramsey/uuid is the standard library for UUID generation. It seems to work pretty well in user-space. However, one could argue that it's "common enough" that it should be universally available. Maybe. A C implementation would undoubtedly be faster than in PHP but... by how much? If it were 10% faster, would that justify inclusion in core? How about 30% faster? 3x faster than user-space? Where is the cutoff for "enough performance different" and "common enough usage"? We have no consensus on that right now, nor do we even ask the question so directly in most cases. We should be, though, lest we just fall back on personal emotional responses. --Larry Garfield