Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128989 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 328A81A00BC for ; Tue, 28 Oct 2025 10:35:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1761647723; bh=kEi8LiWYHKAkzMMLPlbXfViTMbtWSFGG13Nvt8mUU+4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=i7OPdLp+AoyIS4RZKw0z8CyoIIqpHsblPZ7Y9XiIA5sn8z3Z36BloCMvcGPPTOTRl aUVxHdDkfQU0ZR/XRwwbBHfJS82IK/ricFefE6JPl533KwGRoN9ct6dYfuGbuCORcE AZ9WeC95RRdIygjEkCe5vP+1kuW7Qw4akXsAMq3ErpBr0PaS0ZZGDSvDf6MY6lqzhy OMKZLWZXETd5lRW/xG5+sdyR0K/5oqGSryz5jk9nTW7uYajcaWfaqr78+bgnn04aym 3SGqSswdwr++oR67jIrG3J90jnDeaQXU2yog3UpZdVLvMWSI0nUtrPst9uQGBEgoGb 79NCabeJiLaJA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D2CB0180083 for ; Tue, 28 Oct 2025 10:35:22 +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-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) (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, 28 Oct 2025 10:35:22 +0000 (UTC) Received: by mail-oi1-f180.google.com with SMTP id 5614622812f47-44daa894741so693694b6e.1 for ; Tue, 28 Oct 2025 03:35:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761647717; x=1762252517; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=kEi8LiWYHKAkzMMLPlbXfViTMbtWSFGG13Nvt8mUU+4=; b=i5LVFzt5GredwBRxxOMAkTQoyJkpQ65fKEBm/FwK3rsUh5TWWXvzrROg2s5EhYzthq YzyHIjFwAS5KVmLP3vIqUtH0qbkZbmE4IDlrh9NkhdrhfzmOm/ZsXIyoKj5xx+moJEvU QvhBvm0gbVN3Z/prk7hz03wL/YjGqtniZDo93u9wgX1RLdgu3K2c6d8+gOMMdJa3DYSK eO0QHjSOKxgqgnrjumQ6pYs52vPkjy/DRp5p8G1Q8nExhFZnS+TmZC/LDM+vwGArjfSC QHTQxXiL/LzI1bI1u6sRUyYMeqsZninrbyq6BP/FFQbvHgGgFegaAryk/aFxR5uFztRs MP6A== X-Forwarded-Encrypted: i=1; AJvYcCWPVncnlAgcahIO0iOCqaqnyaOJndvsPsVXUIY0dAB7ykL5C0aG8emg1TtmhMcNyIrDLEBtQfg6/Bg=@lists.php.net X-Gm-Message-State: AOJu0YxrynQrq3yLmCwpOlYrAew4krP8pgwx8mlC4cRfLljWO+n7ozdL 8e+AiN6AAktl9IBXTnylNePfo1TmcHZPyBd2bZHw0gJrslqfqwwKYOs8XRGNvrpzTziTYh2sV7q DzMkEucYbsAQJQuWRLUkyGlQebydniN0= X-Gm-Gg: ASbGncsljCv933epZdwv/RkiRV8ETwOELAs2P5lx9Cont26/ojr7GjuWqE/joPdEr8d r3v3ugJes5B4Qqmu+Lc8EuX2vO4PDc9LQCrTqVV57fEt80PJ4L/8cAVBFjH3OeOq+zX98sYs/vZ YvAPPyi+lruX/eLhGgbBdP9nt+EQOWEQhjZVnfhSsBUGi62edfD0aj8XaqqQyOX06GZ88icSVUp SZdlOgufLXn6uQMJa6xhQmB6IUsh2rmLe8En+2xBjeCGsQ2lNJP0FYdbQ== X-Google-Smtp-Source: AGHT+IFZymScLYnQEhItJojzAX6bYazZKD1ajFePPWMX/atmRjQSdlHLNG95uEH68FtzbIujauS1MH5ahtuzdeT0DEU= X-Received: by 2002:a05:6808:80c2:b0:43f:9a39:9d09 with SMTP id 5614622812f47-44f6bb45702mr1236178b6e.50.1761647716708; Tue, 28 Oct 2025 03:35:16 -0700 (PDT) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: <889d3042-7b3e-4152-bd8c-09bbcc967309@app.fastmail.com> In-Reply-To: Date: Tue, 28 Oct 2025 11:35:05 +0100 X-Gm-Features: AWmQ_bkbaoaOzJ8Mw7XKvY3Yvd6pTdFCClWOCa8ZXuuGaZO7gDIt6h2vdiFBK0g Message-ID: Subject: Re: [PHP-DEV] Re: PHP True Async RFC Stage 4 To: Rob Landers Cc: Edmond Dantes , Larry Garfield , php internals Content-Type: multipart/alternative; boundary="0000000000005fb5b50642359292" From: bukka@php.net (Jakub Zelenka) --0000000000005fb5b50642359292 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Oct 27, 2025 at 7:14=E2=80=AFPM Rob Landers wro= te: > > As far as I understand, the only thing missing from php-src that would > allow everything to be async is a Fiber scheduler. We already have tons o= f > Fiber libraries out there ... > I'm not sure if Fibers were particular success. They are quite hard to use and you need an extra library like amp so I think it would be useful to give users a solution that is available in the core. I think this would give it a bit more trust as it will also get the security guarantees (standard core support for handling security issues). It will take time and there will be multiple RFC's to get there and the implementation will also require thorough review. So splitting that to smaller pieces is quite important. That said I'm planning introduction of better API for polling (almost done and soon to be announced) that will be using special polling handles that will be available for streams, sockets, curl and possible other extensions. Streams should then get special notification callbacks that would be called before IO and most likely provide the polling handle as a parameter so this could be used by user space in their own reactor / scheduler. I plan to also provide a similar internal API so async can integrate cleanly into this without overwriting stream polling function as it's the case in the current implementation. Similar API should be also provided for curl (Joe already created part of it), sockets and possible other exts. In other words, the user space should be able to gain this functionality and the async core extension would be more core internal user of it. The above is just for sockets and there will be needed further work for file IO. I'm preparing new PHP IO internal API that will be initially mainly for copying but will allow extension for other operations including file operations and will use io_uring on Linux. I'm still not sure how to best expose it to user space as the ring entry completion don't have usual polling flow so it does not exactly fit into those callbacks. We could possible do some sort pipe and thread that would process the completion queue but maybe there is a better solution. This is still TBD but usually file IO is not the main IO blocker so this can come a bit later. We will also need to think about DNS resolving that might be even trickier and might require IO thread pools - those might be needed as a backup solution for platform that don't support io_uring anyway. I think those API's will be also prerequisites for this async to implement this functionality as I'm not fond of adding some hacks and functionality duplication (that would be quite a pain for maintenance). Kind regards, Jakub --0000000000005fb5b50642359292 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Mon, Oct 27, 2025 at 7:14=E2=80=AFPM R= ob Landers <rob@bottled.codes> wrote:

As far as I understand, the only thing missing from php-s= rc that would allow everything to be async is a Fiber scheduler. We already= have tons of Fiber libraries out there ...=C2=A0

I'm not sure if Fibers were particular success. They a= re quite hard to use and you need an extra library like amp so I think it w= ould be useful to give users a solution that is available in the core. I th= ink this would give it a bit more trust as it will also get the security gu= arantees (standard core support for handling security issues). It will take= time and there will be multiple RFC's to get there and the implementat= ion will also require thorough review. So splitting that to smaller pieces = is quite important.

That said I'm planning int= roduction of better API for polling (almost done and soon to be announced) = that will be using special polling handles that will be available for strea= ms, sockets, curl and possible other extensions. Streams should then get sp= ecial notification callbacks that would be called before IO and most likely= provide the polling handle as a parameter so this could be used by user sp= ace in their own reactor / scheduler. I plan to also provide a similar inte= rnal API so async can integrate cleanly into this without overwriting strea= m polling function as it's the case in the current implementation. Simi= lar API should be also provided for curl (Joe already created part of it), = sockets and possible other exts. In other words, the user space should be a= ble to gain this functionality and the async core extension would be more c= ore internal user of it.

The above is just for soc= kets and there will be needed further work for file IO. I'm preparing n= ew PHP IO internal API that will be initially mainly for copying but will a= llow extension for other operations including file operations and will use = io_uring on Linux. I'm still not sure how to best expose it to user spa= ce as the ring entry completion don't have usual polling flow so it doe= s not exactly fit into those callbacks. We could possible do some sort pipe= and thread that would process the completion queue but maybe there is a be= tter solution. This is still TBD but usually file IO is not the main IO blo= cker so this can come a bit later.

We will also ne= ed to think about DNS resolving that might be even trickier and might requi= re IO thread pools - those might be needed as a backup solution for platfor= m that don't support io_uring anyway.

I think = those API's will be also prerequisites for this async to implement this= functionality as I'm not fond of adding some hacks and functionality d= uplication (that would be quite a pain for maintenance).

Kind regards,

Jakub
--0000000000005fb5b50642359292--