Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129695 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 321D21A00BC for ; Fri, 26 Dec 2025 18:46:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1766774790; bh=vqOFQs4RwN4wpQ75SvrkyyKrRv/yNlf4RrLZSQmszGo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=WV2+EFFFGFbhPlyIWBu/+vml3q+vjvDSGuvpKd1xUInwWzmOAjmEttHEkOSO8qvtZ 8qHyXL1bj/2zr1Mvt8HXUQ0TAxntpIc3WIep2Jat7BAFK9SEdacdtppS32s19wQuOT zIMvUJJxqrFc+xB/mMmaXhc8jJ7omLFtXt9uYcr2yk4YRVAHj0Eo31U4bdKY1igVMO tczp5Umpd6QXySyFTHLLsku2OudMn3D2MTwa4PKfsXuGGrEudpjTbc5KUaOecmYUCX ZygJPhYiXida7RT2GJDYX1TUHgebI/geu4KsdjCTb9A3eQflIUY17PHyo+L+OZgaAX tRaf+orHf02Aw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 92028180080 for ; Fri, 26 Dec 2025 18:46:29 +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=1.8 required=5.0 tests=BAYES_50,DMARC_NONE, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE,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-oi1-f170.google.com (mail-oi1-f170.google.com [209.85.167.170]) (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, 26 Dec 2025 18:46:29 +0000 (UTC) Received: by mail-oi1-f170.google.com with SMTP id 5614622812f47-4558f9682efso4814919b6e.3 for ; Fri, 26 Dec 2025 10:46:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766774783; x=1767379583; 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=dMfwLn5Sj8v282dV4HPTHmdBEZjjXnmR07/4ugVKqXI=; b=jFPeIhavlimJiBAe0qe8gmwH5BWiPjTWKENUnyKfNFUTngrRGxUkGN9yGMuu5ZkUrX fdVkbMrU97v4ChmjSoBEH9Um+hr11ZLZ9OGa+C4u6+DQcL4HtQKVtdwEDsSCUessqsu0 tpJowJdAvosOF0xmyiAqxR/renokHMepK/aawwquoh3nHpfWhkvQTJUdM9AMJKTNXLH7 7uMlSl3A/b/riApxEPO++3eSgJ1o3FLvrDPIEPFm9ZljMB0gLExxY4RfFQbCFcXnYxCe 4uyKKuWHttuaxysYOW6lb6Qv/mQ/iOYDGrXJHufHAT/E2m8+YILMX9RYnLr9unqzfMwg UTPA== X-Gm-Message-State: AOJu0Ywb7N67QxRE/bxicY3wms0CqtZtjyVM5Vz3SjB0uyc75Q87evk9 wC8/8UEqC6701BOQKB/s6JYQT3KIOkKV85U0d3k3v9a4msLxy1Zaa44lC2tluRsB4ZxgWlfkSog oQ5ZTxn0i7v+HgOdnskf4R2pUe1kOIzi70Q== X-Gm-Gg: AY/fxX6hikufrUNBq+MYuXo3E0mnNR0+3Xnf6a8TUl1h1K5z6/VX7ow93/HsuXgi3JF BEjdWO5pId4Y2q9RJiIKDUGV3QFNzdKpHxS0NCWDuGbglUFhWPOft+BS5cHwTSHBhPw45RkeQdo HFsTzgoo3DIstyQEWlOuYFein7Zr/+2atROuC442GJa2gqTUZQKpSkR2oWwXkXbMa5dWqFdRpMs 044RLh6YhXFllyXzUpgn2l7P6iTrB7QbwKrhABSXfHSKsVRDIAFHggB9nFvonXe3wFwdw== X-Google-Smtp-Source: AGHT+IE6CRDWjP12sMTMB00rfeG/L4seVj7Li5jwBkcYndyj72H3JiErHc9rMJH1NaJhQXRWueTeAsPquIVaEydyyoM= X-Received: by 2002:a05:6808:4f51:b0:450:3124:53b7 with SMTP id 5614622812f47-457b214f2f0mr12479982b6e.67.1766774783452; Fri, 26 Dec 2025 10:46:23 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: <0f38bc1a-ba13-43e1-9ee1-70085e75faa6@app.fastmail.com> In-Reply-To: <0f38bc1a-ba13-43e1-9ee1-70085e75faa6@app.fastmail.com> Date: Fri, 26 Dec 2025 19:46:11 +0100 X-Gm-Features: AQt7F2rk6YskdrrQf2Ru3i_I_6jAsrk1-8wsnIh-0DYLmTEEObRm5c8bsHraZT0 Message-ID: Subject: Re: [PHP-DEV] [RFC] Polling API To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="0000000000005daa1a0646df4f04" From: bukka@php.net (Jakub Zelenka) --0000000000005daa1a0646df4f04 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, On Sat, Nov 1, 2025 at 8:23=E2=80=AFPM Larry Garfield wrote: > On Thu, Oct 30, 2025, at 4:06 PM, Jakub Zelenka wrote: > > Hello, > > > > I would like to introduce a new polling API RFC that is part of my > > stream evolution work: > > > > https://wiki.php.net/rfc/poll_api > > > > Kind regards, > > > > Jakub > > I freely admit to not being fully versed in this area, so take my feedbac= k > with however much sodium chloride you feel is appropriate. > > - Given that a lot of people reading this are probably no more versed in > kernel IO polling than I am, a section early on explaining the context of > what is even being discussed would be most appreciated. > > I added a section with some basic explanation so users that are more interested in details can easily search for it. > - I really would rather not add more global constants. Better to at > minimum make them class constants of a class that the new API provides. > (Maybe PollHandle?) > > I replaced them with \Io\Poll\Event enum so this should be covered. There are no global constants. The only constants are now on class and they are for error codes. > - Conversely, I'm unclear why the PollBackend is an enum. That implies > the list of backend implementations is fixed and immutable, and not > extensible now or in the future. I find that claim suspect, as there are > six already. (I find that following the 0-1-many rule in most cases pays > off in the long run.) > This is unlikely to grow and if it ever grew, it would happen only as a new feature in new minor version. Or do we have any policy that disallows extending enums? This is just a theoretical concern though because all the main backends are covered. The only one that could be potentially added is a different variant for Windows if WSAPoll shows poor performance as it was the case in past but not sure if anyone will do such work. > - PollWatcher is created only by PollContext. OK, then please list > PollContext first so that reading PollWatcher I have the, er, context for > where it fits. > > Updated. > - Speaking of, when there's very long code blocks like this I much prefer > to break it up to a block per class, so as to minimize codeblock > scrolling. That makes it much easier to read and jump around as I figure > out how it all works. > > Fixed. > - How would requesting a specific poll backend be helpful, if it varies b= y > OS? If I'm running on Windows, asking for the Linux backend wouldn't hel= p > me much, or vice versa. I don't see the use case here. (Ie, please > describe the use case in more detail.) > There is poll supported on all unix variants and then Illumos has also variant of epoll so there are more than one backend for each platform (except Windows that currently support just one). As noted in the RFC, setting of the backend is mostly useful for testing. The actual enum is more useful to get info of the selected backend. Currently the most useful thing is to find out whether edge triggering is possible. > - Who is the target audience for this? I'm pretty sure it's not anything > I normally work on, so it's hard for me to judge if certain decisions are > good, bad, or "sucky but we have to." Eg, getData() returning "who the > hell knows" strikes me as a footgun in waiting, but I don't have enough > context to know if that's an inherited problem from elsewhere. > Added a section explaining the motivation and possible users of this API. In terms of getData, we would need to have generics to make it typed as this is for user data. You can see the examples that should give you hopefully some idea how this can be used. Kind regards, Jakub --0000000000005daa1a0646df4f04 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

On Sat, Nov 1, 2025 at 8:23= =E2=80=AFPM Larry Garfield <la= rry@garfieldtech.com> wrote:
On Thu, Oct 30, 2025, at 4:06 PM, Jakub Zelenka wrote:<= br> > Hello,
>
> I would like to introduce a new polling API RFC that is part of my > stream evolution work:
>
> https://wiki.php.net/rfc/poll_api
>
> Kind regards,
>
> Jakub

I freely admit to not being fully versed in this area, so take my feedback = with however much sodium chloride you feel is appropriate.

- Given that a lot of people reading this are probably no more versed in ke= rnel IO polling than I am, a section early on explaining the context of wha= t is even being discussed would be most appreciated.


I added a section with some basic expl= anation so users that are more interested in details can easily search for = it.
=C2=A0
- I really would rather not add more global constants.=C2=A0 Better to at m= inimum make them class constants of a class that the new API provides.=C2= =A0 (Maybe PollHandle?)


I replaced them with \Io\Poll\Event en= um so this should be covered. There are no global constants. The only const= ants are now on class and they are for error codes.
=C2=A0
<= blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l= eft:1px solid rgb(204,204,204);padding-left:1ex"> - Conversely, I'm unclear why the PollBackend is an enum.=C2=A0 That im= plies the list of backend implementations is fixed and immutable, and not e= xtensible now or in the future.=C2=A0 I find that claim suspect, as there a= re six already.=C2=A0 (I find that following the 0-1-many rule in most case= s pays off in the long run.)

This is un= likely to grow and if it ever grew, it would happen only as a new feature i= n new minor version. Or do we have any policy that disallows extending enum= s? This is just a theoretical concern though because all the main backends = are covered. The only one that could be potentially added is a different va= riant for Windows if WSAPoll shows poor performance as it was the case in p= ast but not sure if anyone will do such work.
=C2=A0
- PollWatcher is created only by PollContext.=C2=A0 OK, then please list Po= llContext first so that reading PollWatcher I have the, er, context for whe= re it fits.


Updated.
=C2= =A0
- Speaking of, when there's very long code blocks like this I much pref= er to break it up to a block per class, so as to minimize codeblock scrolli= ng.=C2=A0 That makes it much easier to read and jump around as I figure out= how it all works.


Fixed.
=C2=A0
- How would requesting a specific poll backend be helpful, if it varies by = OS?=C2=A0 If I'm running on Windows, asking for the Linux backend would= n't help me much, or vice versa.=C2=A0 I don't see the use case her= e.=C2=A0 (Ie, please describe the use case in more detail.)

There is poll supported on all unix variants and then = Illumos has also variant of epoll so there are more than one backend for ea= ch platform (except Windows that currently support just one). As noted in t= he RFC, setting of the backend is mostly useful for testing. The actual enu= m is more useful to get info of the selected backend. Currently the most us= eful thing is to find out whether edge triggering is possible.
= =C2=A0
- Who is the target audience for this?=C2=A0 I'm pretty sure it's n= ot anything I normally work on, so it's hard for me to judge if certain= decisions are good, bad, or "sucky but we have to."=C2=A0 Eg, ge= tData() returning "who the hell knows" strikes me as a footgun in= waiting, but I don't have enough context to know if that's an inhe= rited problem from elsewhere.

Added a s= ection explaining the motivation and possible users of this API. In terms o= f getData, we would need to have generics to make it typed as this is for u= ser data. You can see the examples that should give you hopefully some idea= how this can be used.

Kind regards,
Jakub
--0000000000005daa1a0646df4f04--