Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129286 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 78D9B1A00BC for ; Tue, 18 Nov 2025 06:46:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1763448406; bh=yZQM2grhOgptN7SAxMZp4CPcOdqoHubCyrtMF01GINU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=DBM8JkDeiFxP8Jepe0dI3WvznykbFTOcZLcXaQ08edhufH9MC8JJguc/6yWdjyTxb oG2CsgCkTixIWKOJ7/yMQEGb+aIja1l3twwN0UR56xsbeO3Ez2LiDhQyO1KKvfxEjY VkrGl8uYHhIgi/er/fBzzt5BrL/UPHY41RYb53gqye1uEcZhMPHRunmGUHqZ02pz9T rcWSsqpQ9O3GSKViGkjPjMnRrS2WQHwvI/NQrrXm0BqOOwjfjnZg2V8TGNkQgdCPc/ 3wfO3K0Jo4TZBAyMLeps+INh+uXFtXfrK/ltgxTjObanZO4tPm1F3UdbrVsLJliX0s e+QsU2zcjDEPw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 22F13180041 for ; Tue, 18 Nov 2025 06:46:42 +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,T_SPF_TEMPERROR autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-ua1-f48.google.com (mail-ua1-f48.google.com [209.85.222.48]) (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 ; Tue, 18 Nov 2025 06:46:41 +0000 (UTC) Received: by mail-ua1-f48.google.com with SMTP id a1e0cc1a2514c-937262a397eso1396568241.1 for ; Mon, 17 Nov 2025 22:46:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763448396; x=1764053196; 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=yZQM2grhOgptN7SAxMZp4CPcOdqoHubCyrtMF01GINU=; b=dbClz95PZOVUShLomd/8c0sP7iaA56lU9ptvQ6/kn05CTzU8KslSd2tY4WdlGEz2oe gYI0XbHrg9f1FnhbRmlAHMua5sUo4VFCX8W93YyNs7TQP6GElZsb9h/tSGYxyIkO4Zrw GIkXwolriiNwLlVnX+6gZVv1Grcfa06bkyRX9qs+zfNZxnUOjM26jOtUajgcYFYg7Klo 054OfxNzW0mdiKbXciUbaN8sH4wDkEoi/3CWOEpKsjrQGhQRglNzjzDNov0GPJNFIrqO 6Z0oXRJh3c64JplpszQiFmvpJYhEiMEzq0/AAx1MhPA+XVUZd6gLp3fMt70RFN74vKhQ AfzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763448396; x=1764053196; h=cc: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=yZQM2grhOgptN7SAxMZp4CPcOdqoHubCyrtMF01GINU=; b=RcSnJ6vNyy2+RPj0HxDPvn35kLPvsGDzxD+c26aTM3l8gQjK7GJYQYPRKqIDIz/XFR F0l9KJ1h0efPy37H3ncqgAp0xv/lnD4Zpnol5P9L5hs6i8ohZrPLZMWHEuZWXVNGlEIX wW6mKmjMnbCsCrSxwIZR9Q1OZjH7qgLUzjXhUAXk9g4nKU2ZvCWFUHMUrCwVsSbV/W2i jLqneYLLh5Y8w7WtsRISG+QL7YrLS+BAjlWJymQ7Vnvp7qEgx+EjvDz445ZE79duoH+P 7e6BZGgARMy2VrR9k2PfPT1lC8O7JX1u3V/kHl66Z+QUdTSMdAL81hrZ7hdXp8tzbcK+ Fzlg== X-Gm-Message-State: AOJu0Yw1ftO673hYMu4A0pzDN3Sk6xdCifXc+LG+QXbu1wMHPpTPmyD5 hXne3hNe2pp7TC9WarcfTi6fDx7I7wcPqiP4eKF8woBDYElwmkgT54nrUfrPEYnjs1+V0Yk5Gxe SqcbQDB9gbmx2KpKrsPMJfiF9PrDc7+nxnnhbkBE= X-Gm-Gg: ASbGncsaKgj+MK63txdTGl0TaN2QJzW4pbJ0AIzmXPeTkF3OW7p9BCCQ/o2utLoiK0U oN5dfsqEP0kqYJl6sFDn52DRgs2Dn0gsgZElIcFWyS1ChQHLlYUniYf6O2+7roId1+GcEt03dbu SGIfaaXhdMlZou/tTXuCkNiEkxxjViFDQhpidqC36+YKNOofu9lCYsPAXL+rAx6pDzTC7jXgRcR 1j3W52D4G9q/nK0JqVxsyjiBcJJsHR58V+YShVXHQIF6wzw7w75Kb3P8vNOPwBakBBEQJquecxR mLaKkBXq8WF+SqwxcT/p9QTojOJ3 X-Google-Smtp-Source: AGHT+IFXGaq05V+JoasrKpneSbA+8aAnvJoe5NNfU7U3sz3W5OMNq0j8k/+6+czDwExJSileDeDaBEkD9T9MuXXJQ+g= X-Received: by 2002:a05:6102:424b:b0:5db:db1d:e1cb with SMTP id ada2fe7eead31-5dfc567210fmr5055668137.21.1763448395946; Mon, 17 Nov 2025 22:46:35 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: <6618a91c-5393-4f40-88b5-b5041ee09deb@app.fastmail.com> <3e0cf0a1-c1a3-4e05-97ba-0eeb7f559a53@app.fastmail.com> <41c5eed0-dd1b-4ea4-99cf-f6d16682bd7f@app.fastmail.com> <08303459-b4ab-44a8-9795-0fb7f82914d0@app.fastmail.com> <563f3bc0-d7f5-4bb9-915c-1d63601d2300@rwec.co.uk> In-Reply-To: <563f3bc0-d7f5-4bb9-915c-1d63601d2300@rwec.co.uk> Date: Tue, 18 Nov 2025 08:46:25 +0200 X-Gm-Features: AWmQ_bnFx0K04kJwUvSfY8uKnlnexG5BrHhYoF36TDuA7f9TdND6ZbKP5eJtJVg Message-ID: Subject: Re: [PHP-DEV] Re: PHP True Async RFC Stage 5 To: "Rowan Tommins [IMSoP]" Cc: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" From: edmond.ht@gmail.com (Edmond Dantes) Hello. > Larry's "sync" marker would be a change to *run-time behaviour*: when > myFun() begins, the scheduler switches into "linear mode", until the end > of that function. In that mode, when a suspend() point is reached, the > scheduler immediately resumes that coroutine rather than choosing a > different one. This is very similar to the async\protect mechanism, but with a restriction that forbids switching inside IO functions. It is possible to implement this, but other coroutines will experience serious starvation. In other words, it can be done, but it should not be done. Concurrency works well when the programmer follows one rule. Every coroutine must have many suspension points, and the time between these points must not exceed a certain value. This is a typical scenario for web applications. It is not universal. There are completely different scenarios. For example, a PHP linter. For a PHP linter, parallel execution will be more useful. Async functions can also help when combined with threads. The architecture will be as follows. * A job manager that monitors execution where one coroutine is one task. * A pool of threads where there are almost no coroutines. The job manager creates a coroutine that sends a task to a separate thread and handles it. It can also perform IO. In the separate thread, coroutines are not really needed because the code mostly performs heavy computations. Of course, TrueAsync will provide the programmer with a channel for interacting with a coroutine in another thread, and that interaction will also be asynchronous. This approach is 100 percent memory-safe because it fully controls which object is passed through the channel. In other words, by understanding the strong side of coroutines and having tools like a thread pool, a programmer can build PHP applications without true parallelism that will not be inferior to Go. The only downside is that you have to manually split the code into an IO stream and a job worker. This adds a bit of development time, but not critically. --- Best regards, Ed