Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126664 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 6FD891A00BC for ; Sat, 8 Mar 2025 23:12:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1741475392; bh=Ko2eyGtu2UGDnSunI7OJatfRhPvBU/0YuXyI4W05x1M=; h=Date:From:To:Subject:In-Reply-To:References:From; b=ENPoAFKGSBqo4o0vcmvbC/JiXx6g08TWyqQpsIppr/BIeAxGpBt/FFWWqwCL9D/Q8 40y6D7SDmK1rlfe/uA3PmCYVjD+x9cVXvohh5uhRnDGBsV/wz3y2lcZSFnxDyBxSOF KImYfADLEOQw1DXqyMrbP4lAbW3KSBc+93TxjYGRcH3bfoHmFANtxEY2pIu42hEU0P hAB/AUH43Ncl0kwfLt7ZbAJCUVdQq9xsb0KLNsR2aDC0pKRkzz/y0YpWezEluBJksG kPSulWM4F1rsf4kbWQQoqOKeEmsA0Y4SnHOAbDISRDURuxJK6j/v3WkCK2s+xblEpJ d0ZgurNHqT4fQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9C4BC180080 for ; Sat, 8 Mar 2025 23:09:51 +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=2.8 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_PASS, SPF_SOFTFAIL autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from xdebug.org (xdebug.org [82.113.146.227]) (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 ; Sat, 8 Mar 2025 23:09:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1741475544; bh=Ko2eyGtu2UGDnSunI7OJatfRhPvBU/0YuXyI4W05x1M=; h=Date:From:To:Subject:In-Reply-To:References:From; b=ekcoD6v8MCEJzISbSsEkJKT3HzY/bD9Bflmor3BMo9d2wGeAbLqcuiN8rEVEasY3X NMvixPvQZGFc/BQrDu190NEDph5Q3TQOGeVE5sT0FjB338RF906tTrSu0zTjgmpabA LBuPuJUugvBh3zHd8Tr9KMtcj/W+DXhx2Ttew9682ejvSGTOIBq86he55HGg3xa9PY Rz3XZ2M3Y6bYiX6YcBF/cKYMBbg6Lb5G8ZpjDEFHfvy6p62dxlg5XuvGJbARyXC6Ig D0h64YcD9O+JTbWxTLTnHLw89SJSxaUQ83DR4NZ6BDqG9mzGygwKFBITBQi4uu/XyY Cjis2up9ID1EA== Received: from [127.0.0.1] (host109-150-25-108.range109-150.btcentralplus.com [109.150.25.108]) by xdebug.org (Postfix) with ESMTPSA id 3FEE810C038; Sat, 08 Mar 2025 23:12:24 +0000 (GMT) Date: Sat, 08 Mar 2025 23:12:24 +0000 To: internals@lists.php.net, Daniil Gentili Subject: Re: [PHP-DEV] PHP True Async RFC User-Agent: K-9 Mail for Android In-Reply-To: References: <08c8ad0b-e8f4-46e3-99f0-b80748d40b89@app.fastmail.com> <07973EAE-2D83-47A8-8FA0-84286C77C02B@rwec.co.uk> <48d66433-3ae9-4895-8361-7c81a0a3670d@app.fastmail.com> <8599eb8b-d4a3-4cb8-899a-25b134e0d64d@gmail.com> <74c4c726-63aa-44e0-84c9-840e13a65a4f@gmail.com> <77DC5F50-531D-49E8-8BE2-504A19CB5FFD@rwec.co.uk> <676e36e4-0b84-4d8c-b3db-2998831cd79d@gmail.com> <510B8EF1-9D07-41A8-9EA0-7D99CF7BFC91@rwec.co.uk> Message-ID: Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: derick@php.net (Derick Rethans) Hi,=20 To see to be posting a reply to nearly every other email on this thread=2E= I'd recommend you have another read through our mailing list rules: cheers=20 Derick=20 On 8 March 2025 22:28:58 GMT, Daniil Gentili wrote: >>> To make an analogy, it's like saying PHP should have an io {} block, t= hat makes sure all file resources opened within (even internally, 10 stack = levels deep into 3 libraries, whose instances are all used after the io {} = block) are closed when exiting=2E >> >> Traditional PHP offers exactly this: the SAPI lifecycle tracks all file= handles opened within a request, and closes them cleanly before reusing th= e thread or process for another request=2E Essentially what I'm proposing i= s a way to implement the same isolation in userland, by marking a checkpoin= t in the code=2E > >Exposing this in userland offers an extremely dangerous footgun that will= severely limit concurrency=2E > >> As I've said repeatedly, it doesn't necessarily need to be a mandatory = restriction, it can be a feature to help users write code without having to= worry about *accidentally* leaving a background fiber running=2E > >Even its use is optional, its presence in the language could lead library= developers to reduce concurrency in order to allow calls from async blocks= , (i=2Ee=2E don't spawn any background fiber in a method call because it mi= ght be called from an async {} block) which is what I meant by crippling as= ync PHP=2E > >Libraries can and should handle cleanup of running fibers by themselves, = on their own terms, without externally imposed limitations=2E > >It makes absolutely no sense, especially for a SAPI, to force all backgro= und fibers to stop after a request is finished=2E > >It would force users to stop and restart all running fibers on each reque= st, which is precisely the main argument for the use of worker mode: reduci= ng overhead by keeping caches primed, sockets open and background loops run= ning=2E > >PHP itself explicitly offers an escape hatch around the "io {} block" of = current SAPIs, in the form of persistent resources (and again, this is all = for performance reasons)=2E > >Even ignoring performance considerations, as I said many times, offering = this tool to userland is a major footgun that will either backfire spectacu= larly (breaking existing and new async libraries by endlessly awaiting upon= background fibers when exiting an async {} block haphazardly used by a new= bie, or even worse force library developers to reduce concurrency, killing = async PHP just because users can use async {} blocks), or simply not get us= ed at all (because the main SAPI usecase listed explicitly does NOT need pu= rity)=2E > >Regards, >Daniil Gentili=2E