Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126663 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 E6C631A00BC for ; Sat, 8 Mar 2025 22:29:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1741472790; bh=grKbkX5Y/YoE2xhze3nw/72gIrZZbqN1Koi9jKVxZgs=; h=Date:From:To:In-Reply-To:References:Subject:From; b=N7t8/z5Uv1q62D0fONQgeE5vybI2HlUxsJsgsfbsb6u7T8AGjs8avd2BBraueQpKr McMS9G4zES+7mokOzYQxsf8nFvHj8hFx88I6wDACU1tyMz3Dddh3K9lobDn9vXg1NM yINEHJEKKm4zHDphrMTKoSYMClJLSKHMnSRT6967AmPJssmtiSLihAGHwkJiLPsMA9 hPgSfDQq4Qke8kls/Y6wA4ez+7xNCm16jCD3A3mqrMFAhctOwBGXf0MId/zFoNoKh3 9ZmpQDIQUBIHaRYZsgz9NUMTo+MC9wgngNooeILPwGLO4Zxnn01XkIMKzi3ntS0U7h bZW+RR7KxUyAA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DBFE618007D for ; Sat, 8 Mar 2025 22:26:29 +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-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (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:26:29 +0000 (UTC) Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-5e5e22e6ed2so3169754a12.3 for ; Sat, 08 Mar 2025 14:29:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741472942; x=1742077742; 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=cE4l+EBvvMJSQqquB6Re1JReE+/3x9ZyT8EG1E5aLPw=; b=cmWY5oT5CnyuV7ULYl82RPChfUasqgvDeTo+WfKqmkRtAfcI7OcMq+P+6dCQ3l6sbf YhXwY8csx2iap5qkGTM5ZLVia76ZgBdBbFIMO9WdUkjJWKdPSLPCf20X7VmAJyny+1ya c/Xu38G3OcmI4huFqiUdQEDrbV5K4emoqe703wQZH6rhPSg39RsgElho4xUR/dHerP7f d4OGVYbd8ZLhZ3AggMo9YNTYRAB0j9IbVDqKYEIGiGnC1kn0c7YRiQ7/VKzPViDLJKXo Qu+s0I7QGzaDQDumTBIxtcZVustzIYRBI8scK69jcaIHe2DK3o5FEwQ9ZQGvbSB3sb+0 2VIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741472942; x=1742077742; 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=cE4l+EBvvMJSQqquB6Re1JReE+/3x9ZyT8EG1E5aLPw=; b=YNjMK0RXlstgCqiWd36o9oPIG0Il2AP0cV1XoVoD/VjJFCoSU93IaRnh/e9VOsfRJ9 Fnzpg8DYmhX9BbjJhZyIIEH0gt64dB1M9fA292Rxu2kc2Dji9HpeISi0Hbde5Hlxzh8v X0bp2nTupgqt0yt62JS5QLqSzOIc1hQ5MQPGHwfuh95XpWmQ/XTXA86WgHWcHsoRPRPk BOr/6Bzj1AKJtnf5Xl6Eg/SV99BaH3/NHAlhOA1+jtegW5tsFUQg2MfqG36T4iBOoydE MUCJxL5LD6qd/7hIWP8KeLViuILbZsd7Nni6U/46q7NjGiVUCGbMfdJK6a0Dly4eD9Mj 4XBA== X-Gm-Message-State: AOJu0YwOaG71diz3ylw863b/c16TXau+UNAit4Oy3i9tj6NiDfATW8Yv EymuhPpQSEqgdXtxydBIQTBkIyiW2gxQv0+kFx0dfk839Zs9AhygdRIioQ== X-Gm-Gg: ASbGnctrEyTRMXVeI78rx73VYnFd31BlH45vriRSrWbG13WaNW+lYvrm/cHXISCJdsI xwRM5lxVCSLwDVgsYj8mneaJMQIkcq0nrUbQ3GG1rDaweVqmII/NPlkOlzD0y9JM2lbOolYCHOV J0SbJmBcBT/h9MyBwPAMUi2GA10yzJvBwJMXB5lvaObz5bD45mAA047efBj18xWQQ34aDL/oyIl qo5q2sQXTDVcV3qyDQK3wNnuhR1apDSFwbWonl5VTUxTu3fOVg4bior+N4f50QnA1KxSGLvOEg9 hZKVdXZCyLTw2jgFuSl49njuy/b6aZgtphUcMlF5gA5otFdBSa7KRtQ1BV9vkyMv3aP0DQSaufj 53T5ltjVbNLa1tXvi5KLicjXepWfO X-Google-Smtp-Source: AGHT+IEN0U0atHW3tGDScrufJ+PJb2fP5s5aYK0GYTFkXzetToghf0hKwVb8oa2tKD9GtHMmvDkcPg== X-Received: by 2002:a05:6402:520c:b0:5e5:bfab:51f with SMTP id 4fb4d7f45d1cf-5e5e211ad2fmr10963590a12.0.1741472942147; Sat, 08 Mar 2025 14:29:02 -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-5e5c733f4c3sm4640309a12.14.2025.03.08.14.29.01 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 08 Mar 2025 14:29:01 -0800 (PST) Date: Sat, 8 Mar 2025 23:28:58 +0100 (GMT+01:00) To: internals@lists.php.net Message-ID: In-Reply-To: <510B8EF1-9D07-41A8-9EA0-7D99CF7BFC91@rwec.co.uk> 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> <77DC5F50-531D-49E8-8BE2-504A19CB5FFD@rwec.co.uk> <676e36e4-0b84-4d8c-b3db-2998831cd79d@gmail.com> <510B8EF1-9D07-41A8-9EA0-7D99CF7BFC91@rwec.co.uk> 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_12_218946989.1741472938659" X-Correlation-ID: From: daniil.gentili@gmail.com (Daniil Gentili) ------=_Part_12_218946989.1741472938659 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit >> 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. > > Traditional PHP offers exactly this: the SAPI lifecycle tracks all file handles opened within a request, and closes them cleanly before reusing the thread or process for another request. Essentially what I'm proposing is a way to implement the same isolation in userland, by marking a checkpoint in the code. Exposing this in userland offers an extremely dangerous footgun that will severely limit concurrency. > 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. 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.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. Libraries can and should handle cleanup of running fibers by themselves, on their own terms, without externally imposed limitations. It makes absolutely no sense, especially for a SAPI, to force all background fibers to stop after a request is finished. It would force users to stop and restart all running fibers on each request, which is precisely the main argument for the use of worker mode: reducing overhead by keeping caches primed, sockets open and background loops running. 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). Even ignoring performance considerations, as I said many times, offering this tool to userland is a major footgun that will either backfire spectacularly (breaking existing and new async libraries by endlessly awaiting upon background fibers when exiting an async {} block haphazardly used by a newbie, or even worse force library developers to reduce concurrency, killing async PHP just because users can use async {} blocks), or simply not get used at all (because the main SAPI usecase listed explicitly does NOT need purity). Regards, Daniil Gentili. ------=_Part_12_218946989.1741472938659 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit >> 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.
>
> Traditional PHP offers exactly this: the SAPI lifecycle tracks all file handles opened within a request, and closes them cleanly before reusing the thread or process for another request. Essentially what I'm proposing is a way to implement the same isolation in userland, by marking a checkpoint in the code.

Exposing this in userland offers an extremely dangerous footgun that will severely limit concurrency.

> 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.

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.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.

Libraries can and should handle cleanup of running fibers by themselves, on their own terms, without externally imposed limitations.

It makes absolutely no sense, especially for a SAPI, to force all background fibers to stop after a request is finished.

It would force users to stop and restart all running fibers on each request, which is precisely the main argument for the use of worker mode: reducing overhead by keeping caches primed, sockets open and background loops running.

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).

Even ignoring performance considerations, as I said many times, offering this tool to userland is a major footgun that will either backfire spectacularly (breaking existing and new async libraries by endlessly awaiting upon background fibers when exiting an async {} block haphazardly used by a newbie, or even worse force library developers to reduce concurrency, killing async PHP just because users can use async {} blocks), or simply not get used at all (because the main SAPI usecase listed explicitly does NOT need purity).

Regards,
Daniil Gentili.
------=_Part_12_218946989.1741472938659--