Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126680 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 4FAE01A00BC for <internals@lists.php.net>; Sun, 9 Mar 2025 20:54:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1741553517; bh=/T2xtNTtnajeTYgmLlmsNiPcWgc9jJXI4UHfAZYOZnU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=cEP42dFqNOSVoOy636VK2tJbcGwb7n8WkA82hN6joR4o1L39PlVw+CT8LuhWPrZrQ g9G/uKQcQPb1xXt5PEy1OHFEVGUGaZ+Zo8FWk7ZBlr9q0iSk1pEugUKAD0i42LUmpg dMAyCi/5bSiVbTYK1WuzwgLyz5XqbCDOSS1ZNyqvg5kz4SAgs6pq1JBh0z+d9yKj0L dUEdutwDEyzGjXSUxmDOndr6jXGOGA9XCpsvOxUbYeOTEeG43JWrZDsnNCR/AuJNJn QzMWmw0LkGSMgjCjSStcJdY0hvWVOsBsdw7B1DsfCKTH+grloVMklp7Zl1+1wL5YJk bfhS5HgrIK9pg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BBE0D18007D for <internals@lists.php.net>; Sun, 9 Mar 2025 20:51:56 +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=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: <i.miroslavov@gmail.com> Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (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 <internals@lists.php.net>; Sun, 9 Mar 2025 20:51:56 +0000 (UTC) Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-ac25d2b2354so350016266b.1 for <internals@lists.php.net>; Sun, 09 Mar 2025 13:54:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741553670; x=1742158470; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=6MzVyZ179XjeZ0LaivXZEo4s6J1rHvwlkfu2gfcAF1M=; b=ZXB41YddXMcIMKNMcGPWQ3U8I2hj/P1yOopnOB5wId1R/42a5ky2Bz6CP6E/NmoV+J 65Yo8P/9gNwtFuf4ob5hdY9Vmf9UN3uDxLnvogkmDCjALZxQOlRji9cr8N0yi72LRwT3 ikHkJDkGAW/YgpMvBJFzN5uul5i/xya47R1MmaDWMLyUuYUV+xYbGyTxksP3YlMt1Ueb t5z/IDspW/kOqYihZwRP+zIrtZ5+cR53qPHebmiGYx2IM0g69lalzOfhIM75xJEI1TX3 iKUNaX/i7p/kea+PCoeoPQZKww8mlDL4J44GIeV7uoRrQunfg5TzescfPcyAMD5Y2j7j KahQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741553670; x=1742158470; 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=6MzVyZ179XjeZ0LaivXZEo4s6J1rHvwlkfu2gfcAF1M=; b=pcA09eRp1EWHiRC6xX6vP8Vn2EBu8/mdqp1huA3df6D+tOZJ68Muq7wXr0FgwHNfap 8IZ8VVY+ARowaRvBNoV9BnJaI3PxIVFMC4PAavR0D8XhOvC7LyWd5oVYWFnDeeHg/Dt2 EkZj3DC+u23IhsPLbbc+SCmiX/usdKONGEnr7tie8DeDEiiCJ1Bgs13Ti+uMad6u/JXb wERw+ygJ9Ii6EkA4Lh0jZ+0KlQDTJ7j3hPVDFiOwpTYf4zn3Hsg3raeUyfLs2sZ4iOB/ o26gvFuCkyPUJ7UZsyAvhg9ssWPvL81cCNY9dAAbSrMMhpyH4Bl87wU8tu3QAD+/3aWC zWbA== X-Forwarded-Encrypted: i=1; AJvYcCVG/h8gqse1QjpOERZGnhQDAUKTLy9JAlLhxHfjxQn1JtbOWJX7KxNJ/sm0AhZrdjCtdWB0JLp4Q0c=@lists.php.net X-Gm-Message-State: AOJu0Yzo4Q/lindAaJst5pSJCb8hrIH4pauGxYRfy6ijHjNamjDVSqeK keDKQObf9JVxfKQYGDOQo1D+LujT+Nm13mfwe/c4w/YrosM5n/9wD9UnzVJmtuVp+rgEUmN0WaR NRjAzxQ1fL4Q9sQDDHCsWcBZRlFw= X-Gm-Gg: ASbGnctveuXTEI6qlS42RUVxi/FIliIE20gtVujGyEECBdH3y+dzg++mcQtD8j56KPo rXuVxJGngyrzJ9Jquu5NMwkxi2GHFZhh4Z2UXmzCI/HNEp53QrJ7lM4zceMshMb++7r+aus6Mo/ n1uy6hKiwWzYWzI5O7IPGEFHcIcA== X-Google-Smtp-Source: AGHT+IGMJpw9O2TVhFz6pznbsJ1IDXxX7AT6E+B1BMATF965xypz+N+3okDYh8pbEplFgbnxjfrT1uudvjmzG0hSpNI= X-Received: by 2002:a17:906:7307:b0:ac0:6e7d:cd0b with SMTP id a640c23a62f3a-ac252b28345mr1016701166b.34.1741553669274; Sun, 09 Mar 2025 13:54:29 -0700 (PDT) Precedence: bulk list-help: <mailto:internals+help@lists.php.net list-unsubscribe: <mailto:internals+unsubscribe@lists.php.net> list-post: <mailto:internals@lists.php.net> List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <CAMW7n8AJckEDzhGv9BdjNhq8zAdCqb4HsVr56vGi+izw50X6Dg@mail.gmail.com> <CAMW7n8CAbKRY9RZsJNSnehKVv8NNGtygocxc+zHBS4h9iRyUGA@mail.gmail.com> <1b6a5b3b-be9b-4e46-9cc6-b8b7f57b8494@app.fastmail.com> <CAMW7n8AumA6bYZ+7+c3rAEeYj0=35wgmohRbrJbH=fc=Ra0FJg@mail.gmail.com> <e65708a0-5130-4726-b405-e3185562d770@rwec.co.uk> <CAMW7n8CwR3d0CHsABZA_zQh-29EbtoZm8f84CYv5Z4QkBCLC8g@mail.gmail.com> In-Reply-To: <CAMW7n8CwR3d0CHsABZA_zQh-29EbtoZm8f84CYv5Z4QkBCLC8g@mail.gmail.com> Date: Sun, 9 Mar 2025 22:54:17 +0200 X-Gm-Features: AQ5f1JohfqcqdVgsmgSq9gZUcC7jnoAFGEF-o1eQlLOw3KhG6d8MyBOXv_3D2ic Message-ID: <CAGwLL8VZCyffaCpSPnsSM_RHCWFoLkWKNfKM039K9g_2U03wVg@mail.gmail.com> Subject: Re: [PHP-DEV] Re: PHP True Async RFC To: Edmond Dantes <edmond.ht@gmail.com> Cc: "Rowan Tommins [IMSoP]" <imsop.php@rwec.co.uk>, internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000d08565062fef0f26" From: i.miroslavov@gmail.com (Iliya Miroslavov Iliev) --000000000000d08565062fef0f26 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Edmond, The language barrier is bigger (because of me, I cannot properly explain it) so I will keep it simple. Having "await" makes it sync, not async. In hardware we use interrupts but we have to do it grandma style... The main loop checks from variables set on the interrupts which is async. So you have a main loop that checks a variable but that variable is set from another part of the processor cycle that has nothing to do with the main loop (it is not fire and forget style it is in real time). Basically you can have a standard `int main()`function that is sync because you can delay in it (yep sleep(0)) and while you block it you have an event that interrupts a function that works on another register which is independent from the main function. More details of this will be probably not interesting so I will stop. If you want to make async PHP with multiple processes you have to check variables semaphored to make it work. On Sun, Mar 9, 2025 at 8:16=E2=80=AFPM Edmond Dantes <edmond.ht@gmail.com> = wrote: > > > > I think the same thing applies to scheduling coroutines: we want the > Scheduler to take over the "null fiber", > > > > Yes, you have quite accurately described a possible implementation. > When a programmer loads the initial index.php, its code is already > running inside a coroutine. > We can call it the main coroutine or the root coroutine. > > When the index.php script reaches its last instruction, the coroutine > finishes, execution is handed over to the Scheduler, and then everything > proceeds as usual. > > Accordingly, if the Scheduler has more coroutines in the queue, reaching > the last line of index.php does not mean the script terminates. Instead, > it continues executing the queue until... there is nothing left to execut= e. > > > > > At that point, the relationship to a block syntax perhaps becomes > clearer: > > > > Thanks to the extensive discussion, I realized that the implementation > with startScheduler raises too many questions, and it's better to > sacrifice a bit of backward compatibility for the sake of language elegan= ce. > > After all, Fiber is unlikely to be used by ordinary programmers. > --=20 Iliya Miroslavov Iliev i.miroslavov@gmail.com --000000000000d08565062fef0f26 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Edmond,<br>The language barrier is bigger (because of me, = I cannot properly explain it) so I will keep it simple. Having "await&= quot; makes it sync, not async. In hardware we use interrupts but we have t= o do it grandma style... The main loop checks from variables set on the int= errupts which is async. So you have a main loop that checks a variable but = that variable is set from another part of the processor cycle that has noth= ing to do with the main loop (it is not fire and forget style it is in real= time). Basically you can have a standard `int main()`function that is sync= because you can delay in it (yep sleep(0)) and while you block it you have= an event that interrupts a function that works on another register which i= s independent from the main function. More details of this will be probably= not interesting so I will stop.=C2=A0If you want to make async PHP with mu= ltiple processes you have to check variables semaphored to make it work.</d= iv><br><div class=3D"gmail_quote gmail_quote_container"><div dir=3D"ltr" cl= ass=3D"gmail_attr">On Sun, Mar 9, 2025 at 8:16=E2=80=AFPM Edmond Dantes <= ;<a href=3D"mailto:edmond.ht@gmail.com">edmond.ht@gmail.com</a>> wrote:<= br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8e= x;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"= >><br>>=C2=A0 I think the same thing applies to scheduling coroutines: we want the Schedu= ler to take over the "null fiber",<br>><div><br></div><div><p>= Yes, you have quite accurately described a possible implementation.<br> When a programmer loads the initial <code>index.php</code>, its code is alr= eady running inside a coroutine.<br> We can call it the main coroutine or the root coroutine.</p> <p>When the <code>index.php</code> script reaches its last instruction, the= coroutine finishes, execution is handed over to the Scheduler, and then ev= erything proceeds as usual.</p> <p>Accordingly, if the Scheduler has more coroutines in the queue, reaching= the last line of <code>index.php</code> does not mean the script terminate= s. Instead, it continues executing the queue until... there is nothing left= to execute.</p><p>><br>>=C2=A0<font color=3D"#333333" face=3D"Fira M= ono, monospace"><span style=3D"font-size:14px;background-color:rgb(242,242,= 242)">At that point, the relationship to a block syntax perhaps becomes cle= arer:<br></span></font>></p><p>Thanks to the extensive discussion, I rea= lized that the implementation with <code>startScheduler</code> raises too m= any questions, and it's better to sacrifice a bit of backward compatibi= lity for the sake of language elegance.</p><p> </p><p>After all, <code>Fiber</code> is unlikely to be used by ordinary pro= grammers.</p></div></div> </blockquote></div><div><br clear=3D"all"></div><div><br></div><span class= =3D"gmail_signature_prefix">-- </span><br><div dir=3D"ltr" class=3D"gmail_s= ignature"><div dir=3D"ltr">Iliya Miroslavov Iliev<div><a href=3D"mailto:i.m= iroslavov@gmail.com" target=3D"_blank"><font color=3D"#6aa84f">i.miroslavov= @gmail.com</font></a><br></div></div></div> --000000000000d08565062fef0f26--