Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126624 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 A19981A00BC for ; Fri, 7 Mar 2025 19:08:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1741374327; bh=EMOdrZ15ZmYFm3OVhzkSKEXwkvM8/vmqKz6OTD9ZzrM=; h=Date:Subject:To:References:From:In-Reply-To:From; b=W5vLB1qqBYL8QkejLt9Xai1gSq8YqoqPaiXHgRquMJ0lYuyw4ywRK0jp3F3KFTPsp rpshwHAcL5IyR+xDBLxxsNl7svyUxagDodETEy8xEVLBZkXMzwC+/pG4NgfIeMdwsL SJofdoGoeLDqdKB9uuRVZX+TA/0Hm2XM5Xq6Wx5v9fgv9mvQqnF2dF02rqTTjZ+rnx tOy4XiuIhepBDWGU4LFA58AXbSxdN8K1ji7kuofk/+Bv+PYbGvZhhQspi5pyjv61r2 9GeW0GZrKBkSYvQb+IJ/HB76h91zchV3AuZIIuF4tgojsefcM60IkXT8eRGv3+F51K NL98U4U0/k4Ug== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E9E131801D5 for ; Fri, 7 Mar 2025 19:05:25 +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.4 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh-b6-smtp.messagingengine.com (fhigh-b6-smtp.messagingengine.com [202.12.124.157]) (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, 7 Mar 2025 19:05:25 +0000 (UTC) Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfhigh.stl.internal (Postfix) with ESMTP id 1F9AD25401BE for ; Fri, 7 Mar 2025 14:08:00 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-10.internal (MEProxy); Fri, 07 Mar 2025 14:08:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1741374479; x=1741460879; bh=lp1uh6A2Cp sEfCUHxnmuorNDGF6/U6I97vJePAJYc8U=; b=oaxW7cf3NmoJF6+I8Cr98uzhmB 4/Y3Mu0fvPLwaJGqZjyBb5wGAJpb/jTQHBu9STDqZaoHcM+H8yB8wurDRb4QZhG0 9OyERwN8TGctyrQK6p8kbCqYpIy3PYgvg2CBc8LtqpJPExNZq+dEDIIpQAtjo2uz vg6U0mv6QWGmbgmyrzm46YwQu+F1qHdoB8SByVZYGWspFsvcGn9Rc+YZPERNznin PHopsf37rOa6B9Nt6Zk6FvPmh7Eg4t8d2zSBLHmPwO+Fpf4cEYEcPJI6tPKANXw8 CFIXHQxWlWYjK2wJQSoRcyy/vlL3Sa+zeCXs/0wKk03huG/KASQv+Acscvzw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1741374479; x=1741460879; bh=lp1uh6A2CpsEfCUHxnmuorNDGF6/U6I97vJ ePAJYc8U=; b=IONFfgcwXw99iOcFwTGxFqL+1bKuo3g5CacBOBUgziisHRuPl4R u+hAX57j7M9VMt0g0ubuT277+uoYgQHEDmtRfTx37B0/Li0AuLGDoWwpUBZssbjT f4PKid5hr12LVp3W4lWa0rsW7STNjrUOhraVl9fL0ZvWakOonJuGTTXGcGkqP29W XEIW+LIdODC4TJ2pvIMMa2JgRS/46O647uZ8MUVAHXyae667N+vAFzWw1F+xTYmv S8EoBuoEcfteDnPKT8P2zgKxvvqbRGEDHolrrI00sepdDCXj8sFPS3sTZeq03X1M B487p0z9rsVTUg4VX8tTqdgt24lDgH0V2/g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduuddugeeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpegtkf ffgggfuffvfhfhjgesrgdtreertddvjeenucfhrhhomhepfdftohifrghnucfvohhmmhhi nhhsucglkffoufhorfgnfdcuoehimhhsohhprdhphhhpsehrfigvtgdrtghordhukheqne cuggftrfgrthhtvghrnhepheetleeiiefgueduieeuieffvdevheduueefkeejuefgffef tdeitdegtedtleetnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepihhmshhophdrphhhphesrhifvggtrdgtohdruhhkpdhnsggprhgtphhtthho pedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhssehlih hsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 7 Mar 2025 14:07:59 -0500 (EST) Content-Type: multipart/alternative; boundary="------------pccs88E01iOfZgycc1PNGQhS" Message-ID: Date: Fri, 7 Mar 2025 19:07:56 +0000 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Fwd: [PHP-DEV] PHP True Async RFC To: internals@lists.php.net References: <9964db8c-0ffe-43d5-8246-47fc76b07180@app.fastmail.com> <78a03dd0-fd4a-4f4a-ad8a-37e5704f06fc@app.fastmail.com> <23e162f6-54b0-4564-9d79-7b3bdc3d1ab5@rwec.co.uk> <36cee7e3-2ef8-4f96-a72e-e67a99e5f9bb@rwec.co.uk> <779046a0-7c70-45a9-82c4-7c31c502cec2@rwec.co.uk> Content-Language: en-GB In-Reply-To: From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") This is a multi-part message in MIME format. --------------pccs88E01iOfZgycc1PNGQhS Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 07/03/2025 08:48, Edmond Dantes wrote: > There is a B2B CRM built on services. Services are classes > instantiated in memory only once via DI, and all that. We process > requests. Requests are executed within a logical *Scope*. The scope > depends on the *TOKEN* and reflects the following entities: > > * *User Profile* > * *Company Settings* > > We have two implementation options: > > 1. Pass the user profile and company settings to every method. > 2. Use some static variable to make the semantics shorter. > This sounds very much like the same scenario, just different data. The key requirement is to partition the data based on the request. Interestingly, like the previous example, the scope is not per-coroutine, but common to all children of a particular coroutine spawned by some SAPI / networking layer - it seems that some way to "label" coroutines/fibers might be useful. > |Async\Context| is designed to *guarantee memory management*, which is > a key aspect for *long-running* applications. It *automatically > releases object references* when a coroutine completes. The programmer > does not need to write *extra code* with |defer()| for this. > That is a good point, and a requirement which I didn't think of. However, the fact that this didn't stand out in the RFC only reinforces my key points: 1) Having so many different features in one RFC makes it harder to discuss their purpose and design than delivering an overall design first, then adding features. 2) The current Async\Context class doesn't have a clear problem statement. Even with "guaranteed memory management" as a requirement, we could have something much simpler. > If such primitives are not included in this or future RFCs, and > instead are left to chance, *it's better not to accept the RFC at all*. > The "or future" in that sentence is key. I'm sorry if I haven't made this clear enough, but I am *not* saying that none of these features belong in core; I'm not even saying we need to tag a release without them. What I'm saying is that they *don't belong in the initial design document*, at least not in this level of detail. > This is the reason why the current RFC is large. It helps to see the > bigger picture. Once the general principles are agreed upon, we can > split it into parts (Incremental Design). > For me, the opposite is true: the size of the RFC is completely obscuring the bigger picture, because I "can't see the forest for the trees", as the saying goes. I think it's great that you've thought about how these different pieces will interact, but a lot of them can just be sketches of future scope, e.g. > It may be useful to have an Async\Context object which can safely associate arbitrary data with a particular fiber, to use in place of global/static storage. To do this, we need to track the parent-child relationship of fibers, and have internal hooks at the start and end of a fiber's life to allocate and deallocate the storage. An example of what an Async\Context object implementation might look like is [here], but the details can be discussed at a later stage. The fact that the parent-child relationship is valuable is a really useful thing to know for the overall design. The fact that you don't like using strings as hashmap keys is not. As someone not well-versed in the terminology and technology of concurrency, I find it really hard to see which parts of the RFC are far-reaching decisions, and which are just bikeshed colours. As a user, I find it really hard to pick out what PHP code I'll actually write to make use of this - or even whether I'm the target audience at all, or whether this is all likely to be hidden by higher-level libraries. -- Rowan Tommins [IMSoP] --------------pccs88E01iOfZgycc1PNGQhS Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 07/03/2025 08:48, Edmond Dantes wrote:
There is a B2B CRM built on services. Services are classes instantiated in memory only once via DI, and all that. We process requests. Requests are executed within a logical Scope. The scope depends on the TOKEN and reflects the following entities:
  • User Profile
  • Company Settings

We have two implementation options:

  1. Pass the user profile and company settings to every method.
  2. Use some static variable to make the semantics shorter.


This sounds very much like the same scenario, just different data. The key requirement is to partition the data based on the request. Interestingly, like the previous example, the scope is not per-coroutine, but common to all children of a particular coroutine spawned by some SAPI / networking layer - it seems that some way to "label" coroutines/fibers might be useful.


Async\Context is designed to guarantee memory management, which is a key aspect for long-running applications. It automatically releases object references when a coroutine completes. The programmer does not need to write extra code with defer() for this.


That is a good point, and a requirement which I didn't think of.

However, the fact that this didn't stand out in the RFC only reinforces my key points:

1) Having so many different features in one RFC makes it harder to discuss their purpose and design than delivering an overall design first, then adding features.

2) The current Async\Context class doesn't have a clear problem statement. Even with "guaranteed memory management" as a requirement, we could have something much simpler.


If such primitives are not included in this or future RFCs, and instead are left to chance, it's better not to accept the RFC at all.


The "or future" in that sentence is key. I'm sorry if I haven't made this clear enough, but I am *not* saying that none of these features belong in core; I'm not even saying we need to tag a release without them. What I'm saying is that they *don't belong in the initial design document*, at least not in this level of detail.


This is the reason why the current RFC is large. It helps to see the bigger picture. Once the general principles are agreed upon, we can split it into parts (Incremental Design). 


For me, the opposite is true: the size of the RFC is completely obscuring the bigger picture, because I "can't see the forest for the trees", as the saying goes.

I think it's great that you've thought about how these different pieces will interact, but a lot of them can just be sketches of future scope, e.g. 

> It may be useful to have an Async\Context object which can safely associate arbitrary data with a particular fiber, to use in place of global/static storage. To do this, we need to track the parent-child relationship of fibers, and have internal hooks at the start and end of a fiber's life to allocate and deallocate the storage. An example of what an Async\Context object implementation might look like is [here], but the details can be discussed at a later stage.

The fact that the parent-child relationship is valuable is a really useful thing to know for the overall design. The fact that you don't like using strings as hashmap keys is not.

As someone not well-versed in the terminology and technology of concurrency, I find it really hard to see which parts of the RFC are far-reaching decisions, and which are just bikeshed colours. As a user, I find it really hard to pick out what PHP code I'll actually write to make use of this - or even whether I'm the target audience at all, or whether this is all likely to be hidden by higher-level libraries.


-- 
Rowan Tommins
[IMSoP]
--------------pccs88E01iOfZgycc1PNGQhS--