Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129362 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 999B21A00BC for ; Fri, 21 Nov 2025 12:26:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1763727991; bh=xyHLWrPEY83VXbB5M60F4x8CEuNVAmVES59nNIL4OeA=; h=References:In-Reply-To:From:Date:Subject:To:From; b=OK1jVG1Twk2+vsYNQhkV/z0I4UFgRlDzUv1NAZpx1BmuOvvn88Nn2EvHqnxpeYgvT 7jlUebMQ3AiUAeLXhVvIUVBvB6DklEEIkhNPX9tzcrNEa2woXM8p24yZYtuwOeozWE ZnZc8mUT/WBN9htCB/3svCV/OusmkVsWbV5pTWKfSB0Wuk/k7hXxJtL4H3EkCtiNno ae6vqUj0IdIN8Mik/GJgqpOBP3uwZu5pcLj2Q2KAAY/yiYyGVpZnCwaFf2A5wBH+kk GJ1MkU3RRBuyHiiT4oNaYKwlh70KgQAClj9niBZ1Jm8hyvBzcXTs87kY3uuPlaHc/A xIiAKxhs5Kn5A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0F8A0180212 for ; Fri, 21 Nov 2025 12:26:29 +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.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (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 ; Fri, 21 Nov 2025 12:26:28 +0000 (UTC) Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-297d4a56f97so28421145ad.1 for ; Fri, 21 Nov 2025 04:26:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=croquemonsieur-be.20230601.gappssmtp.com; s=20230601; t=1763727982; x=1764332782; darn=lists.php.net; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=aWYg/N/7Olgl/xv4OMAxxsP3kSKlIK0B3E34beWX8Rs=; b=wQKEc6nd1zHD8pc8E4We1+zh+HDuUNZ/dnh+tlI7EoaJqvXKSjjT5KoBJLJhk4txTD mOwtrAsG0MT28C4/Ix9Xoex7Jx05o1n2g8/qqdyL9HFvTbQPgMJU1ZOgqJi9fEarHEq1 NhkH71vPP9cRW0xg3HqT4jOiw6qWody4gTOJkiTDFaXBGWBmw2VX3vFnmkvHxLz9Jkug 1kmIkrVnC8jqrI92tuOjEPZDUCqmgX4pzXd1r250fX9wKVJhmOa1PPcBOehbJ4qHQzbk vQOt8OYxsJeceq+8lFe4kmHQAxSDihrUkyTd2YhyjTYrLvI+zU4Y3B6oHxEqjQ1t+h8s 3zfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763727982; x=1764332782; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=aWYg/N/7Olgl/xv4OMAxxsP3kSKlIK0B3E34beWX8Rs=; b=DWSbZck+AFR/+ONCp770XM8jgwJHmpPBNLsVWgNWq+TKy5qHJChRpRxrtvppv3iyGF kRup8cvCyOFSkJAYMxAa+XO/YkDAqR5RZnEnXpw+DVK7fIJXV4AE9kq2sQmVoVlSyg+R w+vJVh5fPCr+kzyFxfm6+qs+m+8Sm6OOB8Bc0HYL1jFqccPkjXMan1mtfP67YuS39s1Z 5q+VmWMduEqp02C4tSyC/3Pw0DIMEQonL7SxpGE+rLfM/cPD7qIA/BWl1GJ/v4/bdD6B N++08Igos6LtVNZMJ2g6hrGnK46HnSVZTL1xTm10yyGRjQQOj+1aL+2+7hxmy91fHlIj nqtQ== X-Gm-Message-State: AOJu0YxM2VEM+Nh5mnLsp4viheMrYKnjNHhi58TVAKFYQ5Z5kgx7XQc+ LtL1H7uilr7NnTFDeZim6w9aGPkfBWzWNz9HsZQsCpSWMaPbunIHzVh4lIZMrAMxE4bsXscTMv9 ssGbMw4Cnn0mZYGch7VTX1oiAwKrtKWaIiRw3D1/e0yKPbCg/0v+cpDo= X-Gm-Gg: ASbGncvPk//28twa/KnLQOsrA2Uqv7lT49yDV8iWdMQlUQ6mZTB9pEo3ZB760WAWdcM tE2EfMftEi2c06RQYfnydYlJ7W9wkVcK9fK9nofxfifFdzDe1TODWXvTLGdagEFFhuoNZLHKTpU Qawm0mhoGe0FoFA0pqrEuiq5nsn8rGFjRVcEdgROiUHxva4NSmNHqukRx+f4BlOAReGgLnN+Das 5Ta09m5I/Q4x48PFZPV8fCs1eceOo2B/UDf9D+yuYJv1VLVNQhs37MpSPx6VPwJHIS3JWQvpOVr 0y/QfrUcH/UI9rnTjuzbqV+Sa2tnHNTg7EbtogA= X-Google-Smtp-Source: AGHT+IHzycT7EvVv6snPDdYPRixqMnoQ/f+uGBdXftVXCR3+fZrU+FUUZNkz6FdNaVmm6CDZe6DMA2ex/50vB+h36ug= X-Received: by 2002:a17:902:e890:b0:295:9cb5:ae07 with SMTP id d9443c01a7336-29b6c574f95mr29833185ad.38.1763727982290; Fri, 21 Nov 2025 04:26:22 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 21 Nov 2025 13:26:11 +0100 X-Gm-Features: AWmQ_bnGpC7Oo1MEg9EfLQe-1DqoEP6keqYgq8E-FdnjEfAurApEmtslsd_HU_o Message-ID: Subject: Re: [PHP-DEV] [VOTE] True Async RFC 1.6 To: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: bart+php@croquemonsieur.be (Bart Vanhoutte) Good morning from a rather cold but sunny Belgium, About Backwards compatibility & colored functions. Right now, I think there's a problem with the promise of backward compatibility. Unless your application handles shared state perfectly, switching on async PHP is going to cause a lot of problems. Ignoring the problem and asking users to rewrite shared state in their applications is an absolute no-go from me. On the other hand, we could go down the path of colored functions, which is also an absolute no-go from me. We've had this in the past before Fibers were a thing and it was an absolute pain in the ass. Every function only accepted Promise and only returned Promise. Bear in mind this coincided with the rise of static typing and FIG-PSRs where you could get away with it until Interfaces accepted and returned actual types. Having colored functions could mean having to duplicate all interfaces where you would have sync and async ones. This would split the ecosystem in two and kill adoption, no thanks. I would much rather have some solution where we can enable (opt-in) non-blocking/async behavior on a per-project basis. At the very least we'll be able to use it in greenfields projects. Developers who want to add support for non-blocking/async I/O in their existing applications can then rewrite their global state and turn it on whenever they feel ready for it. It's not ideal but I think it's a nice compromise between fast adoption and backward compatibility. I envision a time where you'd look at the documentation of a library and see "ok, this is async-ready" (shared state is dealt with) through some badge or something. --- For people who are questioning whether a feature like this should be added to PHP I'd like to point out a couple of things. 1. Current usage of async PHP is not a good argument. Like I've previously said elsewhere, this is a classical chicken-or-egg thing. Some people think it's not worth adding support for this because nobody is using it but also very few people are using async PHP because it's not a first class citizen in the language. Having a couple of libraries and frameworks supporting whatever async model PHP ends up choosing would increase these numbers drastically. Adding support for this new paradigm in popular frameworks/CMSes and thereby pushing the language and ecosystem forward seems like something the PHP Foundation was founded for (wrong mailing list, I know). 2. About handing off the problem to Userland: you can _kinda_ do things asynchronously in PHP through Userland (I'm talking Fibers) these days, but having async as a first class citizen in PHP core would make things much easier. Currently, the ecosystem is fragmented and you need a lot of libraries and specific knowledge in order to get started. We've been doing this for a couple of years now and only recently we got a decent ORM to work async (one unit of work per Fiber, transactions, ...). 3. I think PHP is especially suited for this paradigm. Web applications require a lot of I/O, whether it is talking to the client, database, filesystem, API's, ... Having the ability to either serve multiple requests at the same time through a long running process or - for example - upload a file to S3 and concurrently write a record registering that file in the database can lower the TTFB of web applications drastically. Moreover, as shared hosting is a thing, spawning more processes or threads isn't always going to be available. I feel like not adding async to PHP in the (near?) future would only be postponing it and risk developers looking to squeeze that extra bit of performance from their applications to _Go_ to other languages. --- On a final note, it's nice to see this discussion is gaining some traction! I've just checked with core ReactPHP developers and they're checking up on the RFC, however, their main concern seems to be the same as others on this list: time. Everything is changing very fast and more time is needed to digest this all and to get used to the idea of this mentally. I agree with others, this is something that we have to do right, so let's take the time to do it right. There's already been an awesome effort by Edmund, let's keep working on this. Best Regards, Bart Vanhoutte Op vr 21 nov 2025 om 13:08 schreef Edmond Dantes : > > Hello > > > I think you seriously underestimate impact of this in the current PHP c= ode bases where many applications depend on global state. > Do I really look like someone who could underestimate memory-related issu= es? :) > > > Now imagine that some popular plugin decides to use async which change = some of its globals (like $post or $wp_query) during the suspension of the = main code. I would assume this could horribly break things. > Or for example, you run an old WordPress on the new PHP 8.5 and > everything breaks. Is that a reason not to release new PHP versions? > No, I=E2=80=99m not joking. That=E2=80=99s literally the essence of the a= rgument. If > something might break, then we shouldn=E2=80=99t do it? > > This is a common story. There is a framework that is adapted to a > technology, and there is a framework or library that is not adapted to > it. > If a framework is not adapted, you simply won=E2=80=99t be able to use th= e > technology. So why is this considered a problem? > However, inside WordPress you will still be able to use coroutines as > long as you don=E2=80=99t call WP functions that aren=E2=80=99t adapted. = You can. So > why is this a problem? > > I can use AMPHP inside WordPress and break WP. > So does that mean we must urgently remove Fiber from the language? > Because AMPHP uses Fiber, and AMPHP implements coroutines. And > coroutines break WordPress. > Asynchrony already exists in PHP. You can write async code today. > Which means you can already do all the =E2=80=9Chorrors=E2=80=9D you=E2= =80=99re talking about. > TrueAsync cannot change that. And no one else can change it either. > So why is this being treated as an argument against it? > > > Don't forget that other code don't have control over the plugin and it = might not even know that async is used there. > Exactly. This means that right now I can use Fiber plus select() to > write async code and break WordPress. > And I can also write a plugin that divides by zero and crashes > WordPress, and WordPress won=E2=80=99t know anything about it. > > > So I'm not sure if this design is compatible with WordPress > > Yes, WordPress is not compatible with asynchrony. I=E2=80=99ll emphasize > again. This is not about TrueAsync specifically. This is about > asynchrony itself. Yes, WordPress and Laravel are not compatible with > concurrent execution. That=E2=80=99s true. > But are you **really suggesting** that because of this, all other > applications should be denied the ability to use it? > Moreover, would you deny WordPress itself the possibility of > supporting asynchrony in future? After all, WordPress can be > refactored. It=E2=80=99s not carved in stone. > > Wouldn=E2=80=99t WordPress benefit from the performance improvements that > async provides? > Wouldn=E2=80=99t WordPress plugins benefit from being able to actively > communicate with microservices and deliver the fastest possible > responses to JavaScript? > > Is this feature really something nobody needs? If yes, then I have no > further questions. > > Async is needed to increase throughput. That=E2=80=99s the purpose. If a = PHP > project doesn=E2=80=99t need it, it doesn=E2=80=99t have to use it. That= =E2=80=99s fine. But > there are PHP projects that do need it.