Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126820 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 930481A00BE for ; Tue, 18 Mar 2025 08:00:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1742284650; bh=rBHqsFenCfJ7tPO/jLZDoCIUm6VoaPbA78239dGFHs0=; h=Date:From:To:Subject:In-Reply-To:References:From; b=a/lIrBDwYkO1uzGDgJhswFnLcVTe5aupSg2pWFbunRlgeUIcfcgn5RvdmUVvMem3f LfW7SMU6P/qUkAAUC8HO+Oo30XRChK3ySQxstXXx2PKhfpcT0nV8Kp+ZU+fZRlUzZm VTbZ5SzKlghUwaml0kbj7MGxMFWkQpRUV09kOzwdUuHeVtjxMAIJ/jIRGj9srNyBlv VyoaSabmx598i7I3bN/6QN0MBW7c8iuYKF2MhF5Z9XEkyDgUj6L0zR/MZpp6X8qtkH BgwagoaSydRxyFrK156DG65R7rAoHFl6j8X8OHKLLio0zKsRKHQJ0LLGLD3zYEE6uN Qlv+APK2BqaHw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BB878180081 for ; Tue, 18 Mar 2025 07:57:29 +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=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,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 fout-a6-smtp.messagingengine.com (fout-a6-smtp.messagingengine.com [103.168.172.149]) (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 Mar 2025 07:57:29 +0000 (UTC) Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfout.phl.internal (Postfix) with ESMTP id 718B81382D2A for ; Tue, 18 Mar 2025 04:00:00 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Tue, 18 Mar 2025 04:00:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc :content-transfer-encoding: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=1742284800; x=1742371200; bh=bP+efVw9zj3v0VsOgRR4kjWhkAkXwqnMENUDQHMtnsE=; b= Qrq/beOYRdeDHVmrQKTBtMaBEpg+Osg3UKtX9Mk6U6lx/Y7x/TamNYOy7IR9kXBL wc+QsWa+KZM4nXHwj9cmYNqcVoURqw3+3vQ+i++UtJMXooFEeP7K73R10+5lm25b 1RE0U5gB/cXBNZdfgIt8APNJGeQYi3SoYx+lDk7KGCSxuehZShCgcqacYe6vcKHI H50qpJtFeHelPRQ6vW9EM+AYrdRIAvGtiwhXNROVUhyTC+usGfus75PClpbDFiGQ 3cNGxcctpLDv96Je4gpgoSOOuywUsCrVwmJ6SntLRdDwYQ0AirkD2kpkNFO+N53v mE+ASqZ0ClogAD98gEnarw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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=1742284800; x=1742371200; bh=b P+efVw9zj3v0VsOgRR4kjWhkAkXwqnMENUDQHMtnsE=; b=6jRVRrNxN2zwkij38 8ewavH49xrnK9W5u9O1SGI7xwXXSaV/8pQKFDs3N0CsNUPA0CEugd7g75KKZF7c1 d6/A3p9xIFjdwWgol+5s3d1RYXOucVhf1KOHpFD6zHX5KxAr7pq/mHcRX69RrIQp q7eoZJka2eLW2Qx2+gUjn1GlNVwavhaqqggejP1zwwKjqUZrWlLFGoNlJV6/5rGV HRzPoXAQMXdeBhZtRQoJ0hZ2m8uyiM82Bi+A2c6PHsnqcUgQ1Ui/ZrtZMDhDXYAX zNy6Bcc1F7k8exL6qmehYL4GvxTOtkZVj20kLb3mGqyUh+Bj8be/G1/Y9qY+AASt asLtg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddugedukeelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhf fvufgfjghfkfggtgfgsehtqhhmtddtreejnecuhfhrohhmpedftfhofigrnhcuvfhomhhm ihhnshculgfkoffuohfrngdfuceoihhmshhophdrphhhphesrhifvggtrdgtohdruhhkqe enucggtffrrghtthgvrhhnpeehleffteeigfevudetfedugedtudevledugeeugeelheei hfehgfdtkeevvefgleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehimhhsohhprdhphhhpsehrfigvtgdrtghordhukhdpnhgspghrtghpthht ohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghlsheslh hishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 18 Mar 2025 03:59:59 -0400 (EDT) Date: Tue, 18 Mar 2025 07:59:58 +0000 To: internals@lists.php.net Subject: Re: [PHP-DEV] PHP True Async RFC - Stage 2 User-Agent: K-9 Mail for Android In-Reply-To: References: Message-ID: Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On 18 March 2025 05:59:07 GMT, Larry Garfield w= rote: >My biggest issue, though, is that I honestly can't tell what the mental m= odel is supposed to be=2E The RFC goes into detail about three different a= sync models=2E Are those standard terms you're borrowing from elsewhere, o= r your own creation? If the former, please include citations=2E I cannot = really tell which one the "playpen" model would fit into=2E I=2E=2E=2E thi= nk bottom up, but I'm not sure=2E Moreover, I then cannot tell which of th= ose models is in use in the RFC=2E There's a passing reference to it being= bottom up, I think, but it certainly looks like the No Limit model=2E The= re's a section called structured concurrency, but what it describes doesn't= look a thing like the playpen-definition of structured concurrency, which = as noted is my preference=2E It's not clear why the various positives and = negatives are there; it's just presented as though self-evident=2E Why doe= s bottom up lead to high memory usage, for instance? That's not clear to m= e=2E So really=2E=2E=2E I have no idea how to think about any of it=2E I had a very different reaction to that section=2E I do agree that some ci= tations and links to prior art would be good - I mentioned in my first emai= l that the "actor model" is mentioned in passing without ever being defined= - but in general, I thought this summary was very succinct: > - No limitation=2E Coroutines are not limited in their lifetime and run= as long as needed=2E > - Top-down limitation: Parent coroutines limit the lifetime of their chi= ldren > - Bottom-up limitation: Child coroutines extend the execution time of th= eir parents Since you've described playpens as having an implicit "await all", they're= bottom-up: the parent lasts as long as its longest child=2E Top-down would= be the same thing, but with an implicit "cancel all" instead=2E >Broadly speaking, I can think of three usage patterns for async in PHP (s= peaking, again, as someone who doesn't have a lot of async experience, so I= may be missing some): > >1=2E Fan-out=2E This is the "fetch all these URLs at once" type use case= , which in most cases could be wrapped up into a para_map() function=2E (W= hich is exactly what Rust does=2E) >2=2E Request handlers, for persistent-process servers=2E Would also appl= y for a queue worker=2E >3=2E Throw it over the wall=2E This would be the logging example, or sen= ding an email on some trigger, etc=2E Importantly, these are cases where t= here is no result needed from the sub-routine=2E I agree that using these as key examples would be good=2E >// Creates an async scope, in which you can create coroutines=2E >async { The problem with using examples like this is that it's not clear what happ= ens further down the stack - are you not allowed to spawn/start/whatever an= ything? Does it get started in the "inherited" scope? You've also done exactly what you complained the RFC did and provided a co= mpletely artificial example - which of the key use cases you identified is = this version of scope trying to solve? I actually think what you're describing is very similar to the RFC, just w= ith different syntax; but your examples are different, so you're talking pa= st each other a bit=2E >I honestly cannot see a use case at this point for starting coroutines in= arbitrary scopes=2E The way I picture it is mostly about choosing between creating a child wit= hin a narrow scope you've just opened, vs creating a sibling in the scope c= reated somewhere up the stack=2E The "request handler" use case could easily benefit from a "pseudo-global"= scope for each request - i e=2E "tie this to the current request, but not = to anything else that's started a scope in between"=2E There were also some concrete examples given in the previous thread of exp= licitly managing a context/scope/playpen in a library=2E Rowan Tommins [IMSoP]