Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129690 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 B4CCC1A00BC for ; Thu, 25 Dec 2025 07:57:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1766649469; bh=uQrXqoeURcGClBOg8Qpkp1TRVZoW7rniLFgJ166fvQs=; h=From:Date:Subject:To:From; b=gRDpLq2gYnMRD4ziFdmGBxRp0Enmhl/ySSO4rbeZzJ/1hLSzFRAgj5aIRu/rovyEi UKTKSfNZ7jiSOSlsfBKV3+rc0Uqugh6oQUTDssJ+nGzC0qLdRiCNJuk4O1WiX93FII nomnjD1RI+4tWA0zSuBUEgwX5ufnELnveMEbburEH3ZsyH7fhaHiee5WZ+78iMaHGJ sf9q4YNvuPc+z457xibbN//54iIXOTdJ7giqoRdvaVXkhv2iw0RylrJ6O2mpq+AZ1h ZXTtUIbyKfvTtA0mRIdqqM8tB9wfGW7O4fdu6AqRuH7KrKqGwFsvqEuf8GemYgLzMJ g3GVjmPDCAaHw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2E793180041 for ; Thu, 25 Dec 2025 07:57:48 +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, 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-vs1-f42.google.com (mail-vs1-f42.google.com [209.85.217.42]) (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 ; Thu, 25 Dec 2025 07:57:44 +0000 (UTC) Received: by mail-vs1-f42.google.com with SMTP id ada2fe7eead31-5dfa9bfa9c7so4608852137.1 for ; Wed, 24 Dec 2025 23:57:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766649459; x=1767254259; darn=lists.php.net; h=content-transfer-encoding:to:subject:message-id:date:from :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Mwu0RHj7amUeEwfeOD8DGI4KdXjo1bSHtRh7f/MblzA=; b=fWdRquqNHiEbGJu+XLnWap2ito8KikSF11sM7hXxJ6PK5wCjRHOUBzv5g0QiUpC+K6 5mfYCauL/8uQDC84Cni6CaPdub3dbVBqLoDIX2PNciPuxKYLXtiWBsoE7wcXP+CtkJ4B Io7A3CDHe7hzjLv8vcB/iVGhy5ID+nNHLERRVIq2KD846RQ+vDSrGsRRQih8y7DQdlc9 cn+Oqi2GSF+L/TXxyQpSRLCyROZxCafpowUPHJ/5QQmxJnpsyo2EFxa7wYCiKbWlnNii sSLrNg6haAWLWaBT40Lg/fJSzzHL2Mo4LXtf4mAXfTPSBEGIt4lDvdSYrIiTblEU66jN 4vew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766649459; x=1767254259; h=content-transfer-encoding:to:subject:message-id:date:from :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Mwu0RHj7amUeEwfeOD8DGI4KdXjo1bSHtRh7f/MblzA=; b=tX5vxe/b5UCPU4YwE48f098KnhsuioPH5DfXTsGoKM744+/syLfz6f5KltVv2aYgRU TzWVCrRp0Uq2yh2Z9tkoKWgfgd7oe0bzZKvNU23Nm9NTfYA7lGiAlrLGZ0Z6GFZ1cs2/ ZLJBZsRuFNErU02nYRzJJIVp6o0SfG4OpXjwP9smGjwzWBzBAeU0gk4TXyTag5jaWBwC mnlZDXtG6OqyuhRttFejXt9U0GhMaRPAXyHuQIh+stGy4Sz3hRQ7Dg4r8SBtf6F3M1SD gU5ax5ocWlVY8Bs+psDfIKk9CoAfa8px5jZCBUJ/D013ECSuHkj/OctsjQOLSERPO1WI HaoQ== X-Gm-Message-State: AOJu0Yzy29bQgi1iznw2ww78Kbbe7jaDXW1FX24sVpr26XVmGrILUA8S XdWK1iyCn8JjVhmwTekKQflyreLP5W1/sxbg8j5oZVT6EvcvJPKybRNjub4/pYDm7YaCGMvGCSf JYx4ZC5JL/81/2PQy68QNLneE7qvIyny5q/BOQFo= X-Gm-Gg: AY/fxX7tmFV7tyz2vrHawPRF+8IoBMmKN1Hn+Q52Ab0OL2gzhT1P4TdLKpFVJDnaL7/ QfThhEGni9FUO+e//suMNjdAAfnD+bgK4iruQM6V/KpOPeXWfDg9DNn7yLzzxbDFwrOTdoKGuvD Jg8VS8WiCj6BfWeV6E0Uvyp9KWTop3KrUOvEIvFg1TZLZnCdOlgqo/MLtcOQ+KMAP3K8HZf3pob G2FhWlQKuSmDVLCd4UqZDDGeW+TByAKrowccrb5EmB1RDM8lf+T4bFr6RE5RSnutAktdZthoWSo u0+kW1vMy87VLmxea6T8e+sagDo= X-Google-Smtp-Source: AGHT+IHYWW1o/udvxkXrLA0XHVZGylt5BKByuAtHm28ghT6EQLoakHA9CLDAWKJg+MFWFk+tHFBA9gTfBuS9dZbTLP0= X-Received: by 2002:a05:6102:4a92:b0:5dd:8991:d761 with SMTP id ada2fe7eead31-5eb1a62b56bmr6482895137.8.1766649458905; Wed, 24 Dec 2025 23:57:38 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Date: Thu, 25 Dec 2025 09:57:28 +0200 X-Gm-Features: AQt7F2oUOfxxHQE-XjGwlKIKK3DL5gnLy9z4O_UdD6Vo_M2BlkvQBXpOm4wo9lw Message-ID: Subject: [PHP-DEV] [RFC] True Async RFC 1.7 To: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: edmond.ht@gmail.com (Edmond Dantes) Hello everyone! RFC https://wiki.php.net/rfc/true_async Here is the seventh version of the RFC, revised and expanded. ## Version 1.7 (December 2025) - **Fiber integration:** added `Fiber::getCoroutine()` method, ownership model, deadlock resolution - Added Coroutine methods: `getId()`, `getResult()`, `getException()`, `getTrace()` - Refined *Goals* section: improved clarity and technical accuracy of core value propositions - Function naming aligned with PHP coding standards: `currentCoroutine()` =E2=86=92 `current_coroutine()`, `gracefulShutdown()` =E2=86=92 `shutdown()`, `getCoroutines()` =E2=86=92 `get_coroutines()` - Method renaming: `Coroutine::onFinally()` =E2=86=92 `Coroutine::finally()= ` (brevity) - Interface renaming: `FutureLike` =E2=86=92 `Completable` - Exception renaming: `CancellationError` =E2=86=92 `Cancellation` (clearer= semantics) - Moved `Cancellation` to the **root namespace** (`\Cancellation`) as a fundamental PHP mechanism - Changed `Cancellation` inheritance from `\Error` to `\Throwable`, following Python=E2=80=99s `CancelledError` pattern - Added backward compatibility notes for the new root namespace class - Renamed `DeadlockException` to `DeadlockCancellation` ## My Comments Since the vote took place, I have tried to bring together specialists in asynchronous programming to discuss the RFC, and I was surprised by the lack of serious disagreements. You can read the discussion on GitHub, where key opinions from representatives of different libraries and components are expressed. These discussions became the basis for refining the RFC. Compatibility research involving WordPress, Laravel, and AMPHP helped clarify future prospects and potential challenges. As part of the research, Xdebug was also adapted, without which debugging WordPress code in coroutines would have been inconvenient. A special version of Async-Worker for FrankenPHP was also developed. Memory models were not included in the RFC because none of them provide significant benefits, do not make the code noticeably better, and all of them have drawbacks. Instead, future versions are expected to introduce a separate API and philosophy for multithreaded coroutines. I returned to the original idea of defining the Cancellation exception directly in the PHP core. This was always the right decision, and it should not have been abandoned. The most important change in this RFC is support for fibers as an extended form of coroutines. It turned out to be a great idea. I finally came up with a good term to replace FutureLike, which had been really annoying me. ## Experiments To understand which code breaks, a special version of TrueAsync was created that made GLOBALS unique per coroutine. This made it possible to run WordPress as a stateful application with only a few changes. Two versions of the code were implemented. One where WordPress was fully initialized in each coroutine for every request, and another where WordPress cloned only a subset of its data structures. Similar experiments were also conducted on Laravel. No more than 1=E2=80=932 hours were spent on code changes for WordPress and Laravel. In other words, there were almost no changes. Automatic analysis of the Laravel codebase showed that the number of components combining I/O operations with shared in-memory state is extremely small compared to the amount of code that can work without changes. Some WordPress functions with static variables continued to work as before because they did not contain any I/O operations. Overall, it became clear that the vast majority of the code remains functional in a concurrent environment and works without changes. This means that transparent async can actually save developers time and money. ## Key Conclusions - **One-thread coroutines** are a powerful pattern for web-oriented programming languages, providing a balanced trade-off between system complexity, code safety, and developer ergonomics. - **Coroutines running in other threads** do not contradict the one-thread model. They require further development and can integrate organically, complementing each other=E2=80=99s functionality. - **Actors** are likely to become the next key pattern for multithreaded programming. Their implementation is clear, feasible, efficient, and surprisingly safe. - **Memory isolation and transfer mechanisms** between PHP threads will not conflict with the current RFC. Instead, they will complement it and coexist alongside it. I think having two tools for async, concurrent coroutines and inter-thread interaction, can complement each other very well, and most importantly, they can be built gradually, step by step. This is, of course, a brief summary of the events of the past month, so if I missed anything, please feel free to ask. Merry Christmas to everyone!