Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126661 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 682381A00BC for ; Sat, 8 Mar 2025 22:06:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1741471460; bh=Zd4Cx9oK8chaMNVBS38roFKAgwMLCjONhfGMZOanlt4=; h=Date:From:To:In-Reply-To:References:Subject:From; b=bcaG1zkBKBNe8mensEBB6kMknW8LZ/pESvIpLY+ben1l7qx9R0dA1NtQwneoTVCm7 E2WAh0o0eat0I02px6Zcx2a+9cSETIULIAhHK1BYJqeM+ozziIESSyCogPHbPbxP+5 08k6XYaEfgDQEBSAyYyuhVXLFhqrhXXjqoERM2RtNhKrdp0JTVp2CPOhmGZ802LAPK S2IgtwsLWWqI5VhJOkWw/cW934HC5w+QLTn7WC0gORPGgi1He9cO5ee/Fue4PYNrjz 67rprQ9NqskgI8ZD2zbotNKAWNRNAndpX0ueXNGw4pI9OLavIFYfvvGlnW23ifoRfH Tk9icfND+e35Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 612081801E3 for ; Sat, 8 Mar 2025 22:04:19 +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.0 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (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 22:04:19 +0000 (UTC) Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-5dc89df7eccso4978089a12.3 for ; Sat, 08 Mar 2025 14:06:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741471612; x=1742076412; darn=lists.php.net; h=mime-version:subject:references:in-reply-to:message-id:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=62myhalJFcoh4ZqWHJJDEX6z4CBqIO54Cc/6IgEu/q0=; b=lAkj1hZbd7S+2Su9hA8fE8xFS1XS0SoI7oKaXRGXk+as0geBMjcfaV0/XIKCQUqdRY m/ea8LSY4Q+HIRMNf1Oolf8ldPQLdS4Y6C3dVComfXfUK50Hs0lTh72YLNg3ikmwX3r0 be1nxn6/BAqsY5nFGlqhPrSVq8+AvVeCUyQzYcm54tVga7e8dXypCQDok+soJKovUk1Y ka89f3WaolPLE8NHjaw2NlzmcfMWAOP9QJDHPsDCFHtZEzHI3JfaXJV8O4VlZKOTVzIC JsDNG8DSyQehnjiKeNzER8BEr5ZCpVW6ek3ztayxkqHVRaACPmCIYnOmTFhuMx4fpZw3 uCWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741471612; x=1742076412; h=mime-version:subject:references:in-reply-to:message-id:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=62myhalJFcoh4ZqWHJJDEX6z4CBqIO54Cc/6IgEu/q0=; b=brGyQltH9ltxDgVSLhlwis7KrxoW773qn9zCs2aXfglg4tv/EqqM/Ug3v9g/aIOgHx k+pxMT/AXh0MOrbGKDNJsnH7r5m8ivZ7Bmf31SKGGIngoXm/I1F8rSm7N89/AbqbAitN W9qos95ArDPL9LDfMA6rFVSRgHXUz0HyWKqJF7oJu6JIjhPbIr38u7dIaR07gE1khPcf 8/59hDFMhUShEw/vihE0/Xv2B8UgJ+yQfC1nhlF5jJUgAHwgj5vwLj4un5TwzEg2hVEJ xb8cfrD31Sbe8MnB1HqdTM15oWsxLbZGp2UX2Iw2Lcs4ZedIJiG02VsANFazXaJ/FdQa vL2w== X-Gm-Message-State: AOJu0Yw23u7dcWv8AIPGwrQSwmP3Ajg5msvHBXa6/Y3u+iN+m9rJJYgr I3fPlOc1+j1nOBvv5lRVRG452KJrdtOARg+BoHz4rgiJZYayBjPI6bxwSA== X-Gm-Gg: ASbGncuvE/0vbw1A0SkYy53gxx8AMw3BMKiEQBs2CwJVCZ0euqtf3SsN+qyRNLQ/8TJ IKOQMmvnfJUN3f40lDVxxLATZFjviO4p4PXn8BuL4p73FKcXggNxfxOpFvCkJ5vS1RVWOLATR7Z iJONAYgspIyVskmgvOIxAc58peVl/NCKG0GhnxUIB8B25DcsxLJU3gCaIWbbjOYqnJpkDeoP6WU DpzLBs/HuD6efwcQrG+q732f7vtwOYf5Uy/GzieeueEh2D4JAK7p/TC8TFWNyDkPO8SjExZS08s qB8e3zAyR/GL7JM1Cu4YVNT4pb9pB6rLObxqI03gZg1XKEUbK0r6UcKevSaDAdb78sFxM+ex5vw QKNd+gGa1raY4SWQ966EFyOkB9y1Q X-Google-Smtp-Source: AGHT+IEJTJaFmU+OFV88kz8DRbrXuVUVyYPaDs6c5axKl7RgK0vZxxifecaIZWDAAzSqavhuFN+ZUQ== X-Received: by 2002:a05:6402:13d3:b0:5dc:7725:a0c7 with SMTP id 4fb4d7f45d1cf-5e5e2298978mr11143225a12.3.1741471612204; Sat, 08 Mar 2025 14:06:52 -0800 (PST) Received: from ?IPv6:::1? (luna-749a6f85f554075d0000f.net.as198747.daniil.it. [2a0e:97c0:38f:0:d570:455f:58f6:a947]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5e5c733fca8sm4367905a12.4.2025.03.08.14.06.50 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 08 Mar 2025 14:06:51 -0800 (PST) Date: Sat, 8 Mar 2025 23:06:48 +0100 (GMT+01:00) To: internals@lists.php.net Message-ID: <86091fdf-d1bf-489a-b5e2-5c80484f2181@gmail.com> In-Reply-To: References: <78a03dd0-fd4a-4f4a-ad8a-37e5704f06fc@app.fastmail.com> <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> <9b7ab30f-5ed6-400d-b941-1291e9185286@app.fastmail.com> <9a2e81e8-3534-455b-879a-5a45c85b3ba7@gmail.com> Subject: Re: [PHP-DEV] PHP True Async RFC Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_6_193608181.1741471608611" X-Correlation-ID: <86091fdf-d1bf-489a-b5e2-5c80484f2181@gmail.com> From: daniil.gentili@gmail.com (Daniil Gentili) ------=_Part_6_193608181.1741471608611 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable >>=C2=A0 Crippling async PHP with async blocks just because some libraries = aren't ready for concurrency now, means crippling the future of async php. >> > How can calling a single function have such a destructive impact on the f= uture of PHP?=C2=A0 Very simple: to make an analogy, it's like saying PHP should have an io {} = block, that makes sure all file resources opened within (even internally, 1= 0 stack levels deep into 3 libraries, whose instances are all used after th= e io {} block) are closed when exiting. The async {} block is a footgun that tries to meddle with what must be an i= nternal implementation detail of the libraries you're using. Even if they were optional, their presence in the language could lead libra= ry developers to reduce concurrency in order to allow calls from async bloc= ks, (i.e. don't spawn any background fiber in a method call because it migh= t be called from an async {} block) which is what I meant by crippling asyn= c PHP. If the async {} block were to ignore *referenced* spawned fiber handles, it= would still be just as bad: sometimes one really just needs to spawn a bac= kground fiber to do a one-off background task, without caring about the res= ult. I.e. the spawned logic may also contain a catch (\Throwable) block with err= or handling, making collection of references into an array to awaitAll in _= _destruct (just because someone might invoke the code from an async {} bloc= k!) pointless and an overcomplication. Amphp's approach of an event loop exception handler is, I believe, the perf= ect uncaught exception handling solution. (Also note that amphp also provides an escape hatch even for the exception = handler: a Future::ignore() method that prevents uncaught and non-awaited e= xceptions from bubbling out into the exception handler). Regards, Daniil Gentili. ------=_Part_6_193608181.1741471608611 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit
>>  Crippling async PHP with async blocks just because some libraries aren't ready for concurrency now, means crippling the future of async php.
>>
> How can calling a single function have such a destructive impact on the future of PHP? 


Very simple: to make an analogy, it's like saying PHP should have an io {} block, that 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.

The async {} block is a footgun that tries to meddle with what must be an internal implementation detail of the libraries you're using.

Even if they were optional, their presence in the language could lead library developers to reduce concurrency in order to allow calls from async blocks, (i.e. don't spawn any background fiber in a method call because it might be called from an async {} block) which is what I meant by crippling async PHP.

If the async {} block were to ignore *referenced* spawned fiber handles, it would still be just as bad: sometimes one really just needs to spawn a background fiber to do a one-off background task, without caring about the result.

I.e. the spawned logic may also contain a catch (\Throwable) block with error handling, making collection of references into an array to awaitAll in __destruct (just because someone might invoke the code from an async {} block!) pointless and an overcomplication.

Amphp's approach of an event loop exception handler is, I believe, the perfect uncaught exception handling solution.

(Also note that amphp also provides an escape hatch even for the exception handler: a Future::ignore() method that prevents uncaught and non-awaited exceptions from bubbling out into the exception handler).

Regards,
Daniil Gentili.
------=_Part_6_193608181.1741471608611--