Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128791 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 8486B1A00BC for ; Mon, 6 Oct 2025 18:47:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1759776395; bh=2yLyy+NTM66X2JaB36lfan8ly4n54VxsGb1ifszN5gM=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=UG7ytY/Jj7a/Yxuap/uMTVOhwHWJz34okWrNpdD+HNewhIrSo8ZyJSKtZcg25nj0y +JS1MSMS9xAviRUY2w/0pwgRzk32l8HMndw1vBiAT2c+9AT0+NlZ3ghlVZBRdNunpj RoyZWZ5uz5ZYmMc0ddZelsFvxGVAcIy3ILayDQrGlOgeLA1NM5U6WLupfU63re++Mh Fe7DrjBfbxtlyth6dLYMJAfiTw1GcH6efbZR6h4M/XM/AzW+5gVOKe6Kc6tV6XxsVe FXPDLwS0xoYC759rVVDrp39UcyYAwFdt6stOiF+YRYiy7PLjBIh3wKhooS+Uaay6Ig faP9NBtaPVuDg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 02A6A1801D7 for ; Mon, 6 Oct 2025 18:46:34 +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_MISSING,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 mout.kundenserver.de (mout.kundenserver.de [212.227.126.130]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) 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 18:46:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thomasbley.de; s=s1-ionos; t=1759776468; x=1760381268; i=mails@thomasbley.de; bh=7bGglu+wRZjdxi68o2WqffIK/T1VAihmtmm+gEzM1ug=; h=X-UI-Sender-Class:Date:From:To:Cc:Message-ID:In-Reply-To: References:Subject:MIME-Version:Content-Type:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=CGh31n4mXKQqC4YRPVo/fUXKSP4ygVongM6QFB/MHYOh07jZTd50aKxCfgSFOK8m +c2kzsPhSNpVZkUuutMMHo29XJWJeaaSIvKMls9hsqKs8APKBKLuhWAfah3Q8ICAB QBsr9JNsUIL192Xp54ehhf+J3DhsFLolzJ7xv3MrXXY4VXcHq9HRjyqihI89ciZx0 +xKSxpDB2xMBmatWyNreWagyWqyJ2yGJDbU+MPXsH1vSbprjcguFSVadh58UjfQ+G tw3ZREjBBSIiQ8NYqzJ3/GtyVmqT5SQpfu5IWQy5b+FOig5+YkV0LZLUweoMGpU+0 KLcMayaqfZBKiOsiAg== X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from open-xchange-core-mw-default-20.open-xchange-core-mw-hazelcast-headless.open-xchange.svc.cluster.local ([10.73.157.156]) by mrelayeu.kundenserver.de (mreue009 [172.19.35.3]) with ESMTPSA (Nemesis) id 1Mc02Z-1uYgxP1iet-00dVPn; Mon, 06 Oct 2025 20:47:48 +0200 Date: Mon, 6 Oct 2025 20:47:48 +0200 (CEST) To: Deleu , Edmond Dantes Cc: Larry Garfield , php internals Message-ID: <453862111.154105.1759776468063@email.ionos.de> In-Reply-To: References: <14f591d4-aa1e-49dc-bc20-03cb493dc20c@app.fastmail.com> Subject: Re: [PHP-DEV] PHP True Async RFC Stage 4 Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_154104_964033218.1759776468059" X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer v8.38.83 X-Originating-Client: open-xchange-appsuite X-Provags-ID: V03:K1:nwAVogQw7otijCDvc/0rk5icEVeuXsTwYGc6fnEc2pCCAMtNJDi 3iI/sPnlJojj4W6oE9j6uFih0GVftpoPqgKQAmV+dA4XTdY/yz07n1f2+kvYK7PeHh7OJV2 uKB8olAKYKGY0qF+fr615h/f20Fr312ch8QdnZVOVZ6k5J5Gkik+QnPEAy77DKJYqYeTX9Y 04c8UlCoJdrMjwxwYrs3g== UI-OutboundReport: notjunk:1;M01:P0:iSN3PTsdjvo=;0mk6ko8XLMfMAWicIAlw5+5iyA2 0zmrbRFfeLviIkXxD//u12v1IoFv9FOd2HQp1PkoYMDTwU4AhKe8O2niNJ8zwRV0DOIVusrvQ t1/ueFf8SZk7e1e8QDZEh7HFFX0MKw2kULeh5UcqVXeV5Er0u2PP+0GJLzb3dL2IoPjCQxhCU 0gOmMfNG/6hslSBtjGt+mTMlBxCzFUW1NYb5syRLPZ/ircv0rk0pCu5yUhST8cPhBmyQeSWoY cXH+m6GggOCIUUoJKqRm/FqM5zYth3sQH8tw9t8GdOXKVZtS2XVaWA9YKw2bFyg4qb8XjFrXe 5aAzDSny6QEfPHQVxtA5VIlYxJhajqbL5TadUUFdPXa0q3JSeUe274MZKXHXGT7q8XSXr96+f 7/v+22I7UlaG6ynny23Tj320hyPDPiGorI4v7U9LEDZVNs10AlltraeQxbGiR1s5/kmRjbg+U MQzYoWpYmJ1Bcrh/K2QCNArOWhcimjTd7OUDiLdM/QkMIcoQwnz6Jk80GzN9UoKnrFDfToNJf 37zZhX+DwGcIh8O1Uz5TzU0PqKdTdx3MlfdgGsoXkzPngem45MvftCTmdPwdqdvUWX1y+iFFJ m7fZlQIoi7UAcdi/VJg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Dxvp idBgHE0gYt5KJsbjFvCbt9 From: mails@thomasbley.de (Thomas Bley) ------=_Part_154104_964033218.1759776468059 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable > Deleu hat am 06.10.2025 19:29 CEST geschrieben: > =20 > =20 >=20 > Hi! >=20 >=20 > 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 com= mon. > >=20 > > 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. > =20 > I find this a bit confusing to contextualize. I agree that most code writ= ten 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 t= asked with optimizing the time it takes for a certain HTTP Endpoint to exec= ute 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 av= ailable 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 execu= tion duration, having async capabilities can easily drive the decision of h= ow the code will be restructured to fulfill the need for performance improv= ements. > > > > That is *A benefit*. It is not the *only benefit*. Being able t= o 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 latel= y you > > sometimes hear complaints that the ultra-trendy immutable philosophy > > leads to terrible performance :)) > >=20 > > 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. > =20 > 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 interpret= ation is that you mean to say that the PHP Developer can choose what to sha= re and what not to share by defining static variables, much like most other= languages implement the Singleton Pattern. In PHP, especially with the sha= re-nothing model, even static variables are cleared out. While there's no d= enying that there is value in creating a shareable space for performance ga= ins, and this is seen in popularization of Swoole, Laravel Octane, FrankenP= HP Worker Mode, etc; there's still a point to be made about the fact that 3= 0 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 po= rt them to newer execution models. This is where I think Larry's point come= s 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 e= veryday and where support of async execution for FPM would be a game change= r 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 databa= se queries. > > > > Remember, in the wild, PHP-FPM and mod_php are by orders of magni= tude the most common ways PHP is executed. React, Swoole, etc. are roundin= g errors in most of the market. And the alternate runtime with the most mo= mentum is FrankenPHP, which reuses processes but is still "one request in a= process at a time." > >=20 > > 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, th= ey > > 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 n= oticeable. > =20 > If you have a report that executes 3 queries and each query averages betw= een 4 to 5 seconds, this report takes up to 15 seconds to run in PHP. The c= apability of executing async code in FPM would mean a 3x performance gain o= n 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 applic= ations contextual logic within a single execution unit. One very common rou= te that is taken with today's options is to break those 3 queries into sepa= rate HTTP endpoints and let the frontend stitch them together which provide= s a very similar performance gain by taking advantage of JS/Browser paralle= l requests since PHP is unable to do so. > -- >=20 >=20 >=20 >=20 >=20 >=20 >=20 >=20 > Marco Deleu=20 I'd like to mention that running queries in parallel can give better perfor= mance, but it depends on the resources available on the database server. In= case disk IO is the bottleneck and a single database server is used, paral= lel execution can be even slower in worst case. For MySQL/MariaDB, parallel execution normally helps (see https://dev.mysql= .com/doc/refman/8.0/en/faqs-general.html#faq-mysql-support-multi-core). For modern analytical databases using by default multiple CPU cores per que= ry, column stores, simd and many other optimizations, parallelization is mo= stly not necessary since the connection time for a new connection is often = slower than executing a query. =20 Regards Thomas ------=_Part_154104_964033218.1759776468059 MIME-Version: 1.0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
 
Deleu <deleugyn@gmail.com> hat am 06.10.2025 19:29 CEST geschrieb= en:
 
 
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.  The example you're replying to is= quite common.

It=E2=80=99s probably my poor English. So I=E2=80=99ll try to rephras= e 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 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 t= his from a different lensis. You're right that just because async is alread= y 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 e= xecution duration, having async capabilities can easily drive the decision = of how the code will be restructured to fulfill the need for performance im= provements.
 

> That is *A benefit*.  It is not the *only benefit*.  B= eing 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 lat= ely 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 ambiguo= us, at least for me, tbh. When you say the developer has a choice, my inter= pretation 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 o= ther 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 performanc= e gains, and this is seen in popularization of Swoole, Laravel Octane, Fran= kenPHP Worker Mode, etc; there's still a point to be made about the fact th= at 30 years worth of PHP code exists in the wild assuming that static varia= bles gets cleared out between requests and as such are a non-trivial task t= o 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" execut= ion models are just a rounding error in the amount of PHP code being execut= ed everyday and where support of async execution for FPM would be a game ch= anger 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 da= tabase queries.
 

> Remember, in the wild, PHP-FPM and mod_php are by orders of magn= itude the most common ways PHP is executed.  React, Swoole, etc. are r= ounding errors in most of the market.  And the alternate runtime with = the most momentum is FrankenPHP, which reuses processes but is still "one r= equest in a process at a time."

Almost no one wants to spend time building code with a technology tha= t
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= noticeable.
 
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. T= he capability of executing async code in FPM would mean a 3x performance ga= in on a report like this. That is far from just a few milliseconds gain. An= d to be honest, the biggest gain for me would be the ability to keep the ap= plications 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 pro= vides a very similar performance gain by taking advantage of JS/Browser par= allel requests since PHP is unable to do so.
 
--
Marco Deleu

I'd like to mention that running queries in parallel can give better per= formance, but it depends on the resources available on the database server.= In case disk IO is the bottleneck and a single database server is used, pa= rallel execution can be even slower in worst case.
For MySQL/MariaDB, parallel execution normally helps (see https://dev.mysql.com/doc/refman/8.0/en/faqs-general.html#faq-mys= ql-support-multi-core).
For modern analytical databases using by default multiple CPU cores per = query, column stores, simd and many other optimizations, parallelization is= mostly not necessary since the connection time for a new connection is oft= en slower than executing a query.
 
Regards
Thomas
------=_Part_154104_964033218.1759776468059--