Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125145 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 2BB421A00BD for ; Fri, 23 Aug 2024 14:13:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724422539; bh=SwCme1VwoML5BZf0CNGPjO1YsTfZdF5gfcGPaWowOec=; h=Date:From:To:In-Reply-To:References:Subject:From; b=h75ltr3HYORdHz3ekbfWYIYOTFYHSjpEaCvnXG+jpqr4/K3xRuwU+72ZWTYbC8VtW m/R8Whrz9m/xEHv+3up2cIkG88K0cP316n88rZYc6WjJL5tVRLbsp8Pv2fUHne8fWn V8eG9LxAkthF12VchV4XozvCG8wXKJyT2gbsoZauKl05X9SnN9EioJpHKDeEmwvcfM G3JI2NYcJzaiVzSsSGckj9MGRGxJtQw/4X+RywUCnjzA/LY/9Q41KdKSb/84BB2nI2 o82F6+y/85jhFHSsk+ChPbwZAq1OKWn8v2f5fTZRenipkpq5bNSGANuPvIGuZY4QL3 +SAbqMt5go3kQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1841E180034 for ; Fri, 23 Aug 2024 14:15:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fout2-smtp.messagingengine.com (fout2-smtp.messagingengine.com [103.168.172.145]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 23 Aug 2024 14:15:38 +0000 (UTC) Received: from phl-compute-03.internal (phl-compute-03.nyi.internal [10.202.2.43]) by mailfout.nyi.internal (Postfix) with ESMTP id BC71C138FFC8 for ; Fri, 23 Aug 2024 10:13:46 -0400 (EDT) Received: from phl-imap-06 ([10.202.2.83]) by phl-compute-03.internal (MEProxy); Fri, 23 Aug 2024 10:13:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to; s=fm1; t=1724422426; x=1724508826; bh=a0y3o+RKvTT6Ypihp95+E 8OIHwwiUhawoNYtvULkD5M=; b=C2xnDL65BRXTrr7yQa4siosO35Smo2ALgxG2o ncKbCtMF8FIDrwJ7SbJG3H3dS/11V3WZcJOyDJacaboRcwhcO2przbd4Dexi7gAs poTRpMQaLSjrUgfu6xyQrDwAuNPV3ljwGpgQOyy8ipTjaOvlGtMK/g90twt8mEdl /+7MFUS8adoV4RiqRBSXNGFanEtx3p/uqoUqCwhcRrihC51IyQP/vHj/1YWB/1ai G9RtJ3e8pwrHCPRe9tGGiJJxPEcibHIlFl1uL6+r7dy4s/r4uhEhFNfxVPeVowhW MwM/ocS14ZqUaUyjyjG/tWK0uGVLQ5/xutVV5XzhOUGZCWcbg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1724422426; x= 1724508826; bh=a0y3o+RKvTT6Ypihp95+E8OIHwwiUhawoNYtvULkD5M=; b=H Zb0XF9RQ3+QWMSygovArKzToQcIFDKSFF1kyySYEp0g8BhhJRkm3gvrJSLhss91C +vDdLiIYcMSevjdHFFIx0pzrfq6jOlbb1bGa5x71dgnDNCHtLyNrDFTu54LF0/w1 qGRABuAXKVBKWSdzBSGBTBHJRfNmi0VAEVAdNv6HJndANUVjNH0jHfmHvhGl/gWt vZg848u8B/gLog5SousT+ed2i0SFuRLlQhzuCm7uCyLSz6CvpZGQgVaUIkRFXT9y KVIhWSyt2UKYDBB4U6jDwhQ73r07PJEtW0G9EzxronSmaCilwDZAWn2NyO30THQW KRA4KGoXOOJi2K4IkWb5g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddvvddgjeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepofggfffhvffkjghfufgtgfesthhqredtredtjeen ucfhrhhomhepfdfnrghrrhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfih gvlhguthgvtghhrdgtohhmqeenucggtffrrghtthgvrhhnpeffieeivdfhvdeguddttdeg teeiueegvefhteehfeeffeetudeitdehtdegjeeuieenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggt hhdrtghomhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpth htohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 7635129C0064; Fri, 23 Aug 2024 10:13:46 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Fri, 23 Aug 2024 09:13:19 -0500 To: "php internals" Message-ID: <98675de0-cc1e-465f-8cde-507e03371ce3@app.fastmail.com> In-Reply-To: References: <1b59392a-68cb-36eb-0fef-977ac7113520@php.net> Subject: Re: [PHP-DEV] State of Generics and Collections Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Fri, Aug 23, 2024, at 4:58 AM, K=C3=A9vin Dunglas wrote: > Thanks for sharing this research work. > > Instead of having to choose between fully reified generics and erased=20 > type declarations, couldn't we have both? A new option in php.ini coul= d=20 > allow to enable the =E2=80=9Cerased=E2=80=9D mode as a performance, pr= oduction-oriented=20 > optimization. > In development, and on projects where performance isn't critical, type= s=20 > (including generics) will be enforced at runtime, but users will have=20 > the option of opting to disable these checks for production=20 > environments. Strictly speaking, yes, a disabled-types mode could be made regardless o= f what happens with generics. But the downsides of that approach remain= the same. I'm personally against type erasure generally, in large part= because I don't know what it would break in terms of reflection, and in= part because I *know* people will turn it off for dev, too, and then en= d up writing buggier code. > If this is not possible, the inline caches presented in the article,=20 > combined with =E2=80=9Cworker=E2=80=9D runtimes such as FrankenPHP, Sw= oole, RoadRunner,=20 > etc., could make the cost of enforcing generics negligible:=20 > technically, types will be computed once and reused for many HTTP=20 > requests (because they are handled by the same long-running PHP script=20 > under the hood). As working runtimes already provide a significant=20 > performance improvement over FPM, we could say that even if=20 > non-performance-critical applications (most applications) will be a bi= t=20 > slower because of the new checks, people working on=20 > performance-sensitive applications will have the opportunity to reduce=20 > the cost of checks to virtually nothing by switching to a=20 > performance-oriented runtime. From talking to Arnaud, the main issue here is the file-at-a-time compil= ation. I'm not entirely clear if a persistent process would side-step t= hat, with the delayed resolution bits, or if those would have to be re-r= esolved each time. (That's an Arnaud question.) Another possibility th= at's been floated a bit, tangentially, is allowing some kind of multi-fi= le loading, which would allow for a larger scope to be included at once = as an opcache segment, and thus the optimizer could do more. That said, I suspect the benefits of the JIT when using a worker-mode ru= nner would be larger anyway. Also, speaking for me personally and no one else, I am still very much i= n favor of official steps to improve worker-mode options in php-src dire= ctly. What form that takes I'm not sure, but I would very much favor ma= king worker-mode a first-class citizen, or at least a one-and-a-half cla= ss citizen, rather than its current second-class status. --Larry Garfield