Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126557 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 qa.php.net (Postfix) with ESMTPS id ACD331A00BC for ; Mon, 3 Mar 2025 19:59:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1741031814; bh=fNmHH14v9aNnhWXGWP3BXT6XDoFKF5rFeNr/X1Pz9Is=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kJs9VfXx4Wuhn1iNC41of85ayCng+wXB6EomPZS1qhjpbCXyREexNhaop00KECYLB iYZXNYDfFUNQyC09Y6ZrZvl68xN/EkqmarFO4bqJ5JEl3GsG4sMl5sa2N5OaSWfZEW kJTFSJyN4xIDiKuLmxCD269pCSss/xpBXeB2T37NGvggQrhLb93fZCLvuiTB2SSk9M cbIdYFQ6crZ1sa0fxF2U7NjSMHtu1I8npWt7SsfCTgnBStOZSqU5E79m6iA0tfeaZs lCg/la0D1RTrDMKo+ku0SBNQi41ZgoAT/82Dfup969vrHnqu3H154sgJGyldrcCYU/ N3JaIToPXx32Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EEF2E180082 for ; Mon, 3 Mar 2025 19:56:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_FONT_LOW_CONTRAST,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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, 3 Mar 2025 19:56:53 +0000 (UTC) Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-30613802a59so55565461fa.0 for ; Mon, 03 Mar 2025 11:59:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741031969; x=1741636769; darn=lists.php.net; h=mime-version:user-agent:references:in-reply-to:date:subject:cc:to :from:message-id:from:to:cc:subject:date:message-id:reply-to; bh=Il9yOV8jzCMZZkNzhUmW17Np7RMbxs77ZX6c72C5XfE=; b=ATiTof2m9VtKvJOictGl6sb/FdbQAtksi0x2MDx4BcqgusJJRiwlSAEnWKMpoc2yPG ObNvV2+gACFJPw87+lKS2Zp+GmVHJQ+nBoWd85UCVyRfKwtsR3KUywKVb+EAHkl7anzu QCuAgD8jE0P+3sRg4lsdkk2y51dawsnE4znZbvExi4MvM8KySiHPa1ILT1Iq8vTQi/Fr gpQNxSFeJoEfshu47Tp5cBC8a9zoI2j4dXiMTkk/IDDe/+Cpp3midOTQcCM0pPS9Q6ZS MK7rwjcFsWet1Rkr1SRfjX3gkAu6z6FmcWnelTslnd7S4394A03fn3cKSRGkPTEqg3po 1+Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741031969; x=1741636769; h=mime-version:user-agent:references:in-reply-to:date:subject:cc:to :from:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Il9yOV8jzCMZZkNzhUmW17Np7RMbxs77ZX6c72C5XfE=; b=wTcFRAgXcpo+m5BWiaYEGpQrna3kSQDFqthX1KBeOOb5QicchEUcuHIIAE9GMihg+m Ego+wP0xM9U5FyiVTj5IwWXHR7HMJi4lZTwNDjTtkCVymMVbVT+A8iPCzLlmaV7tiyCW HeEaChMWxzv8U0w91XTo5dxFtL2HS1Nmd4OzFeOHTj3pDYwo4boKysO0PfJ6iHzr/GhV tHy7KVrFAFA+R2TMJCBeH99m/4yFtrYe2c/1/holC2WPFQNUsZr7D1CSgRWBcVkuFj5I HAYzd0bWWM26r93JOYvfnpRs5he+TUFz4Yr8FIGN10ofzKYYZrB+d0cP4FHi2XHFUmWt YNTQ== X-Forwarded-Encrypted: i=1; AJvYcCXD5959rYC9fhXgq9LMZe6ChQSCQBXs4JIPbEytP+4jC69Xer+aUz0rySLwTqM+X/vAsIzthRd1EC4=@lists.php.net X-Gm-Message-State: AOJu0Yw0Nn0+FzPLsQwINOYrtjPUYdDsttJ3m22nvsIe/gPCHBgKaJfO bL5tdnwbAL6frbWXyp8vr1Kh8q/OZPic+HE798CLoWlNBnXPxRxl X-Gm-Gg: ASbGncuSc9ZkjOXfzOPWdl04xPLBuBvjX/X4+WD06FoRN05iZM6kwbcFvV3s/kuwfTw U3Zrm8UQod+thACybzM28Ea7KtwTLUjiNVC2kHPEKFB6HWSeaKGtoD6O+XUK5DC49cddnWZxcWj FC+jvoPwXoXNoosY3ul6fH9v+nZALBC1mKyyTFe7gQzFqf9IWefMAuWqa/xbMADGEbv4ySyabzl Q6ylUlIBlWy0Q7RvCVwE3ibPwwMXYkQpf1UD3TG/T6/o5TvOnKG0Jtin87XgDY0OTZA+Oj/OIlc Mj++OhSaEJoFkVOVLxgUvLUexKO5IVtnc1Mz/jPDFI/T7YcSDmXgjp20i2/EAk9S X-Google-Smtp-Source: AGHT+IGGdjtW7jrS+PecrvCVxyr8rnkC6Gn+U+DrcqVltZxCGjxa45dyn5zxuFWo3h4ReJtvvtPqDg== X-Received: by 2002:a2e:be10:0:b0:308:ec6f:7022 with SMTP id 38308e7fff4ca-30b93223632mr50234271fa.17.1741031968267; Mon, 03 Mar 2025 11:59:28 -0800 (PST) Received: from noip.localdomain ([77.239.166.57]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-30b867ca1dfsm14637051fa.58.2025.03.03.11.59.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 Mar 2025 11:59:27 -0800 (PST) Content-Type: multipart/alternative; boundary="----sinikael-?=_1-17410319664900.013714842001225191" Message-ID: <1741029042833.2240251697.2286506290@gmail.com> To: Nicolas Grekas Cc: Daniil Gentili , internals@lists.php.net Subject: Re: [PHP-DEV] PHP True Async RFC Date: Mon, 03 Mar 2025 19:59:26 +0000 In-Reply-To: References: X-Mailer: Vivaldi Mail User-Agent: Vivaldi Mail/7.1.3570.50 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 From: edmond.ht@gmail.com (Edmond Dantes) ------sinikael-?=_1-17410319664900.013714842001225191 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hi, Nicolas. Hi Edmond, The target DX is that when outside any event loop, we're still able to leverage fibers to provide concurrency, for requests only, and when inside an event loop, requests run concurrently to any other things that the loop monitors. Is that something that could be achieved with your proposal? If not, maybe that's the split we're wondering about? This RFC leads to PHP operating in two modes: Blocking mode: The Event Loop needs to be implemented manually, AMPHP works. This is how PHP currently operates. Concurrent mode: Code runs in coroutines. The Event Loop works under the hood. AMPHP does not work. If we try to imagine a way to keep PHP in a single mode, it would likely require implementing coroutines separately from Fiber and leaving Fiber as legacy. This solution has both advantages and disadvantages. Advantages: Switching can be optimized considering the new architecture. The Event Loop will start automatically when needed. Code using Fiber will work as before, and most likely, AMPHP will be able to create an event loop in user-land. Disadvantages: More work is required. There is a risk of ending up with a Frankenstein-like result. :) A relative advantage of the current implementation is that it changes only about 100-500 lines in the PHP core (probably even fewer, since part of the changes are in extensions like CURL and Socket). The downside is that it cannot change the rules that were previously established. -- Ed. ------sinikael-?=_1-17410319664900.013714842001225191 Content-Type: text/html; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit
Hi, Nicolas.

Hi Edmond,

The target DX is that when outside any event loop, we're still able to leverage fibers to provide concurrency, for requests only, and when inside an event loop, requests run concurrently to any other things that the loop monitors.

Is that something that could be achieved with your proposal?
If not, maybe that's the split we're wondering about?



This RFC leads to PHP operating in two modes:

  1. Blocking mode: The Event Loop needs to be implemented manually, AMPHP works. This is how PHP currently operates.
  2. Concurrent mode: Code runs in coroutines. The Event Loop works under the hood. AMPHP does not work.

If we try to imagine a way to keep PHP in a single mode, it would likely require implementing coroutines separately from Fiber and leaving Fiber as legacy.

This solution has both advantages and disadvantages.

Advantages:

  1. Switching can be optimized considering the new architecture.
  2. The Event Loop will start automatically when needed.
  3. Code using Fiber will work as before, and most likely, AMPHP will be able to create an event loop in user-land.

Disadvantages:

  • More work is required.
  • There is a risk of ending up with a Frankenstein-like result. :)

A relative advantage of the current implementation is that it changes only about 100-500 lines in the PHP core (probably even fewer, since part of the changes are in extensions like CURL and Socket).

The downside is that it cannot change the rules that were previously established.

-- 
Ed.
------sinikael-?=_1-17410319664900.013714842001225191--