Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128790 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 lists.php.net (Postfix) with ESMTPS id 93D721A00BC for ; Mon, 6 Oct 2025 17:30:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1759771724; bh=wwqshRlm3PJrNNKIlZiwoyb3KXJAwlWfYBzIOI4lUrI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=OrZ7YJfM1+rOkeoCSuCbXkY7pTMdPPBqvSKskBJgtvHVbBQr0S5GhnS8TUI6WIYt3 br2ewS+mP3GaDhhTD4SkHP2Dl3+KdKuR5TZxLHLFvBoUAYEzNTv4Re4KkO/6RPx6oX 4T9nFlFyfe6rwRablLRHWB8vr7AbRBMm7Rtp/uW1dGWMzjRi/berwpVJ1eFdA4CVIi pPvpfdC8QbuZCaliwLZl6I7pMqKCMNaG8XLk08uf9VVtTWpaiW69KWrOYkeHQn72ZC ipWcO7mT5BUpaKAv7It6hMNFmCxGBCl4ozWHjHpQve4L2/NS/+uT2BufOg20WTMn/M HL6EJO5L39etA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 057A61801E8 for ; Mon, 6 Oct 2025 17:28:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,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.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170]) (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 ; Mon, 6 Oct 2025 17:28:39 +0000 (UTC) Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-780c6c40772so2055377b3.3 for ; Mon, 06 Oct 2025 10:29:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1759771796; x=1760376596; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=PcEqRLNi4olAmNfqIN7a4gaEIhplPVVNbTcfeA1unqo=; b=bTDVFuysULc/xH6PZeeogikvBQ64DNoypYbyLhBQ/LcE+eRyfhV7fRrqFjQCEy3Gxd rTC/JKYnkOKKe0ZIplVCX/k8XbbiR8QYBuma9TqN9OFKX+V/7miomXhU9erx7GZ0M/dt VDsVh2e/lgza7cWL+qrYAQRFNuS9QZdYD0kf3dJz0/zTM9B/dX6YDvVOhTtbat6yl6/E veRXpbwjx2VOgP/ChQXX5vjue9BP2ai/c8puzGipICiGJPvIbWKhRB3jjpBJptaxNCLO CDtMCuNTbZ1zSJ0PlubXFXU6+KUapZzB79gL19X+TmXO54SUwmKIOhuaDn7L3JMMAYxN gUEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759771796; x=1760376596; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PcEqRLNi4olAmNfqIN7a4gaEIhplPVVNbTcfeA1unqo=; b=jQcR6hiuYYzr21SznHqJ0RF2bgbXDdfZUY6q53VsWhfJ6X2d+trNJLyy5aYyCsL96/ 5VP85Cg9mnsbE1FQFhnQlje4ErMVWku0HuSE/HVxlOgAeHbknrMjqeyD5OCnCpwpogFm ysALSPAGuDiClz3VVwOEAlkCrOS/u6cas6A25n1r0EyEMKEXvdTg9WRf0c1nGPNq3bu7 OtcXVtq/mW4YDqV0U/9JNO1CrJy+Qupuqc8hpPYGD2YneXbdss+0qRjW7bf8as4HOxys lmfrPsazKoy3kPeNUCp4EW6r9O/SbcB+LgS6oPTje17j3xS7yJZ/7EYl+dWvbD6INGTK 8NeA== X-Forwarded-Encrypted: i=1; AJvYcCV0Yrh33UMeuO/z+a/G65nu0ZhJZdHCt8rCbPUmwj+pvrzqwL0h+n4Z13pVBhinSmS9+IvTHMU78J8=@lists.php.net X-Gm-Message-State: AOJu0YzVuCgGLkb5axPPhDfLHHfxjH5DonK9I4H2kCEc32XZ91LXcVMk d0Xd6zcLoYRlUj6tFJQNlavnfAnOQgcrdZ969xfEFk77EMnMAajzWO6p5qTK5eaWuKcTGOClBQR ulWXVktuNu4/F1uQUQXpIewjrK6BkTrk= X-Gm-Gg: ASbGncvEuF2BwQ4oxUtcCxZHSshD7F0BKUOL2/mi8xjU0iEK5hTq+WfRog/hiuqMff3 AdO9QveYlYwy0yM6u8jq9IX4Cpror8axGFlKhQj0MGA3qTKc62uxtEmnHWgsQocEk1vwoFlmk5E 3GvSgfwhYq773YeGVCKaz0zSzKS7lrUcVLB8HL4lfxhmwzjbbnuU1xcqIFTaYipdN20WghAyj0f gTBycFrgAZuM+Jh2hYIIfJfZMq2D/S++5U8PQ3u1Ms6ei8/Kn0z/iiy/0r8P9PYpvF4kmmUDkM= X-Google-Smtp-Source: AGHT+IFc2TX7HwCKHqfqQiYGOtTibVROQG0wIjmCGCi0+vdQCTQKjY5EAvAMh9ZjOk96dMR0n614PWbpz2Kjc9pA7oM= X-Received: by 2002:a05:690e:4290:20b0:63b:b79e:d2b5 with SMTP id 956f58d0204a3-63bb79ed3eemr4547468d50.10.1759771795692; Mon, 06 Oct 2025 10:29:55 -0700 (PDT) Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: <14f591d4-aa1e-49dc-bc20-03cb493dc20c@app.fastmail.com> In-Reply-To: Date: Mon, 6 Oct 2025 14:29:19 -0300 X-Gm-Features: AS18NWD7sPRyNH4pFZ2_f45G3t9DlNxLIU53O38ju8RiXoHKe7b5GgBK3ROsano Message-ID: Subject: Re: [PHP-DEV] PHP True Async RFC Stage 4 To: Edmond Dantes Cc: Larry Garfield , php internals Content-Type: multipart/alternative; boundary="000000000000c49f97064080cc6b" From: deleugyn@gmail.com (Deleu) --000000000000c49f97064080cc6b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi! On Mon, Oct 6, 2025 at 1:43=E2=80=AFPM Edmond Dantes = wrote: > Hi. > > This is simply not true. The example you're replying to is quite commo= n. > > It=E2=80=99s probably my poor English. So I=E2=80=99ll try to rephrase th= e idea: > The majority of database queries are executed sequentially, step by > step. Not all queries. Not always. But most of them. > This is true even in languages that already have async. > I find this a bit confusing to contextualize. I agree that most code written was probably written following the principle of 1-query-at-a-time, even in languages that already support async. But at the same time, if you're tasked with optimizing the time it takes for a certain HTTP Endpoint to execute then caching data OR rethinking query execution flow are among the top contenders for change. What I'm trying to say is that I would look at this from a different lensis. You're right that just because async is already available doesn't mean that queries will take advantage of it by default. But for the critical parts of a system that requires optimization of the execution duration, having async capabilities can easily drive the decision of how the code will be restructured to fulfill the need for performance improvements. > > > That is *A benefit*. It is not the *only benefit*. Being able to > compress the time of each request in a shared-nothing model is absolutely > valuable. > (It=E2=80=99s important not to overestimate this model, otherwise lately = you > sometimes hear complaints that the ultra-trendy immutable philosophy > leads to terrible performance :)) > > A stateful worker does not automatically mean active sharing of state > between requests. It gives the developer the choice of what can and > cannot be shared. You have a choice. If you want all services to > follow the immutable model =E2=80=94 you can do that. But now you don=E2= =80=99t have > to pay for compilation or initialization. You have complete creative > freedom. > Talking about stateful workers and shared-state here is a bit ambiguous, at least for me, tbh. When you say the developer has a choice, my interpretation is that you mean to say that the PHP Developer can choose what to share and what not to share by defining static variables, much like most other languages implement the Singleton Pattern. In PHP, especially with the share-nothing model, even static variables are cleared out. While there's no denying that there is value in creating a shareable space for performance gains, and this is seen in popularization of Swoole, Laravel Octane, FrankenPHP Worker Mode, etc; there's still a point to be made about the fact that 30 years worth of PHP code exists in the wild assuming that static variables gets cleared out between requests and as such are a non-trivial task to port them to newer execution models. This is where I think Larry's point comes strong with the fact that most these new "modern / non-legacy" execution models are just a rounding error in the amount of PHP code being executed everyday and where support of async execution for FPM would be a game changer for code that is too hard to lift-and-shift into worker mode, but not so hard to make adjustments in the next PHP upgrade to e.g. parallelize database queries. > > Remember, in the wild, PHP-FPM and mod_php are by orders of magnitude > the most common ways PHP is executed. React, Swoole, etc. are rounding > errors in most of the market. And the alternate runtime with the most > momentum is FrankenPHP, which reuses processes but is still "one request = in > a process at a time." > > Almost no one wants to spend time building code with a technology that > isn=E2=80=99t supported. So when people want to do things like that, they > simply choose another language. > I=E2=80=99m not saying that async isn=E2=80=99t supported in CGI mode... = but.. > it=E2=80=99s just that a gain of a few milliseconds is unlikely to be not= iceable. > If you have a report that executes 3 queries and each query averages between 4 to 5 seconds, this report takes up to 15 seconds to run in PHP. The capability of executing async code in FPM would mean a 3x performance gain on a report like this. That is far from just a few milliseconds gain. And to be honest, the biggest gain for me would be the ability to keep the applications contextual logic within a single execution unit. One very common route that is taken with today's options is to break those 3 queries into separate HTTP endpoints and let the frontend stitch them together which provides a very similar performance gain by taking advantage of JS/Browser parallel requests since PHP is unable to do so. --=20 Marco Deleu --000000000000c49f97064080cc6b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi!

On Mon, Oct 6, 2025 at 1:43= =E2=80=AFPM Edmond Dantes <edmond= .ht@gmail.com> wrote:
Hi.
> This is simply not true.=C2=A0 The example you're replying to is q= uite common.

It=E2=80=99s probably my poor English. So I=E2=80=99ll try to rephrase the = idea:
The majority of database queries are executed sequentially, step by
step. Not all queries. Not always. But most of them.
This is true even in languages that already have async.

I find this a bit confusing to contextualize. I agree that= most code written was probably written following the principle of 1-query-= at-a-time, even in languages that already support async. But at the same ti= me, if you're tasked with optimizing the time it takes for a certain HT= TP Endpoint to execute then caching data OR rethinking query execution flow= are among the top contenders for change. What I'm trying to say is tha= t I would look at this from a different lensis. You're right that just = because async is already available doesn't mean that queries will take = advantage of it by default. But for the critical parts of a system that req= uires optimization of the execution duration, having async capabilities can= easily drive the decision of how the code will be restructured to fulfill = the need for performance improvements.
=C2=A0

> That is *A benefit*.=C2=A0 It is not the *only benefit*.=C2=A0 Being a= ble to compress the time of each request in a shared-nothing model is absol= utely valuable.
(It=E2=80=99s important not to overestimate this model, otherwise lately yo= u
sometimes hear complaints that the ultra-trendy immutable philosophy
leads to terrible performance :))

A stateful worker does not automatically mean active sharing of state
between requests. It gives the developer the choice of what can and
cannot be shared. You have a choice. If you want all services to
follow the immutable model =E2=80=94 you can do that. But now you don=E2=80= =99t have
to pay for compilation or initialization. You have complete creative
freedom.

Talking about stateful workers= and shared-state here is a bit ambiguous, at least for me, tbh. When you s= ay the developer has a choice, my interpretation is that you mean to say th= at the PHP Developer can choose what to share and what not to share by defi= ning static variables, much like most other languages implement the Singlet= on Pattern. In PHP, especially with the share-nothing model, even static va= riables are cleared out. While there's no denying that there is value i= n creating a shareable space for performance gains, and this is seen in pop= ularization of Swoole, Laravel Octane, FrankenPHP Worker Mode, etc; there&#= 39;s still a point to be made about the fact that 30 years worth of PHP cod= e exists in the wild assuming that static variables gets cleared out betwee= n requests and as such are a non-trivial task to port them to newer executi= on models. This is where I think Larry's point comes strong with the fa= ct that most these new "modern / non-legacy" execution models are= just a rounding error in the amount of PHP code being executed everyday an= d where support of async execution for FPM would be a game changer for code= that is too hard to lift-and-shift into worker mode, but not so hard to ma= ke adjustments in the next PHP upgrade to e.g. parallelize database queries= .


> Remember, in the wild, PHP-FPM and mod_php are by orders of magnitude = the most common ways PHP is executed.=C2=A0 React, Swoole, etc. are roundin= g errors in most of the market.=C2=A0 And the alternate runtime with the mo= st momentum is FrankenPHP, which reuses processes but is still "one re= quest in a process at a time."

Almost no one wants to spend time building code with a technology that
isn=E2=80=99t supported. So when people want to do things like that, they simply choose another language.
I=E2=80=99m not saying that async isn=E2=80=99t supported in CGI mode... bu= t..
it=E2=80=99s just that a gain of a few milliseconds is unlikely to be notic= eable.

If you have a report that execut= es 3 queries and each query averages between 4 to 5 seconds, this report ta= kes up to 15 seconds to run in PHP. The capability of executing async code = in FPM would mean a 3x performance gain on a report like this. That is far = from just a few milliseconds gain. And to be honest, the biggest gain for m= e would be the ability to keep the applications contextual logic within a s= ingle execution unit. One very common route that is taken with today's = options is to break those 3 queries into separate HTTP endpoints and let th= e frontend stitch them together which provides a very similar performance g= ain by taking advantage of JS/Browser parallel requests since PHP is unable= to do so.

--
=
Marco Deleu
<= /div>
--000000000000c49f97064080cc6b--