Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126544 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 8A7611A00BC for ; Sat, 1 Mar 2025 19:33:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1740857450; bh=CLkV6dwhRdhiyYTVomiq/ujeC7EcHZXU4fkKlhEjllI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=RXeYQpxWWVBQMz3FJYziYzuPgoXg0GDsrLgD5/37HYjJyXXalGpqudcInQS+L9x/l aM6ldAxGqPbXvPZv0Ye8RdHtS148salN5AfcaIetHAdb6sLr7XbUobcNOl3gwwHwpL yeyu4GfqPBfYwiaIxzwLAjq07P83uXGy6vEAgM1tDOPBzXBKR6sSvkiBur6D1pd2ZG Kftci41PX4LuCFCAMzb7I8xdNKPsIqyASG25FJUt5pzfqnDRrr0PYW8w9JpR3afjy0 rQMaf+XvxxbWt+q5K1DJEUFqx/ebz9wGrjltbIeN19KuBK5hg7zNv6PVaa3JQ7hdhq VrO0mHEroZs+w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1F8FB18004E for ; Sat, 1 Mar 2025 19:30:49 +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.2 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f177.google.com (mail-yb1-f177.google.com [209.85.219.177]) (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 ; Sat, 1 Mar 2025 19:30:48 +0000 (UTC) Received: by mail-yb1-f177.google.com with SMTP id 3f1490d57ef6-e461015fbd4so2287778276.2 for ; Sat, 01 Mar 2025 11:33:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740857605; x=1741462405; 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=CLkV6dwhRdhiyYTVomiq/ujeC7EcHZXU4fkKlhEjllI=; b=bgcWiTQF8lrpo9xf7wV/xfycRoE47U3msCE6kZA98bE3JymXvZRaF7IlUozhA+oHsi Ax6MmW4HKsTecZG9IcxeC4mAtHrdFS3/her6YQ011hrQ0pPTyO5Z6nGn6aCBOJSyN8pW YkNbxQmOlxhvKBQbqh0YGQbmM96sRUga9gMVKRKgSnQsXANKLBbCxTUQHQ3yKbMxlwS6 EHJ0V8xUpez8lqgV5i1I4PjolDPKfNlz7cJ7Xz+xR2Kpnd8knPDjKXZd8XssU2efD+pk RrEobGrT2cub6jIzNIPuiQPce4lEmc8ANo5BQEkXhcx5AQSoQTVc2Atiloenb/gcDFqT f5vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740857605; x=1741462405; 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=CLkV6dwhRdhiyYTVomiq/ujeC7EcHZXU4fkKlhEjllI=; b=C2cAOnBUt1N97JhqcckmTOT6GLdmWF+cLjbJL33O6mV2RaG/CKTHKwkgFb7N67u3HA +TOYRPuMB9pWTM3oaNg+MKvkwTB3unek9JcdbiaThu1Zad4dCsZombOg7ApKp0HdMgFN t7vb/5yXnN/VOEjiXA2TW5mv+Taak8TI2ZIiN9sx34DDQ0rosTjKu3Iq/Bptrm6/BPGW S2wEM7kLUUK3xWXY89qUD6VWNnEAH3Xwx/l8pKT0j4XOVfW1pNHdgFJQjCfEZUT4YFU7 iNANCWAUPKZD8XSQs9XquR8mXbrcZWBgdIJS34OnwUZLd2rZAHfU0IbDDZCBp3Cu2SgT PINg== X-Gm-Message-State: AOJu0Yw/P6epEZquRCvXa25abRTBIfXEPBx4RSAzkU7dQ+gkdSK3lp7A KZhew4fuv1inT1nSmRWyf7EsQ9axJ5zSqOa6zrKeG/AIdCLzZflX9JYHRjCwy70HMq06xxpl5s1 T2Rmjele+ueGsVjSjBUC2VocQY3YuvhOf X-Gm-Gg: ASbGncsL6t6VsfEk9SVYSVzUxWgh4YNBILy6Vho7Fj6q7wiBiDZopcB2B3IzmYGvYfy LQ45w+OX7dzq2KUOqRVAeyLZ7HdGGfTVfnAP/W4sQxUiOG6CBsr+hUXmTPEbUFvY3eYNgi+8xr1 ME8lmgpRCcydqeo2bLsDy6vhoX2w== X-Google-Smtp-Source: AGHT+IGs2JvFLy0QvWp8b91RYzMYPzvsPpuyot+maIsegrZIZ7Zjkhw2akpJRHg1ntdw+sTjjhDJaDC3DHNgrBakMHE= X-Received: by 2002:a05:6902:2310:b0:e5e:1816:bfcf with SMTP id 3f1490d57ef6-e60b2e86080mr8703187276.1.1740857605370; Sat, 01 Mar 2025 11:33:25 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 1 Mar 2025 21:33:14 +0200 X-Gm-Features: AQ5f1Jp2MqmKgtxszDFKDJMqJilE99_mDB5nRCuT3jaOtraZdIqkElGj2eXAAHY Message-ID: Subject: Re: [PHP-DEV] PHP True Async RFC To: Rob Landers Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000002c3cad062f4cff8e" From: edmond.ht@gmail.com (Edmond Dantes) --0000000000002c3cad062f4cff8e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > but it would be interesting to replace the scheduler with something that > utilized go-routines for true multi-threading. Whether that works or not, > is a whole different can of worms. > > =E2=80=94 Rob > If the question is whether it is possible to interact with a PHP thread from another thread by sending an event to the Reactor, the answer is yes, it is possible. Moreover, from the PHP-land side, this could be a Channel. If the question is deeper =E2=80=94 replacing the Scheduler with a Schedule= r in another language or from a different ecosystem =E2=80=94 then it is more li= kely possible than not, considering that the module itself is separated from the rest of the implementation. If you know a situation where this would be useful, then why not. For example, in cases of integration with a web server, we can just send a message through a channel from "server-thread" to "php-thread", and in a microtask written in C, for example, create Fibers to handle the request. This approach is used in Swoole. And this solution should be even slightly faster than in Swoole because the interaction will occur through memory copying within a single process. If memory copying is to be avoided, then the web server can be integrated directly into the Reactor, making the web server itself run as a microtask. Since the memory will be allocated immediately in the correct thread, there won=E2=80=99t even be a need to copy it, which in some cases might provide = a performance boost. Or maybe not... Ed. --0000000000002c3cad062f4cff8e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

but it would be interesting to replace = the scheduler with something that utilized go-routines for true multi-threa= ding. Whether that works or not, is a whole different can of worms.

=E2=80=94 Rob
If the question is whether it is possible to interact with a PHP thread fro= m another thread by sending an event to the Reactor, the answer is yes, it = is possible. Moreover, from the PHP-land side, this could be a Channel.

If the question is deeper =E2=80=94 replacing the Scheduler with a Schedule= r in another language or from a different ecosystem =E2=80=94 then it is mo= re likely possible than not, considering that the module itself is separate= d from the rest of the implementation. =C2=A0
If you know a situation where this would be useful, then w= hy not.

For example, in cases of integration with a web server= , we can just send a message through a channel from "server-thread&quo= t; to "php-thread", and in a microtask written in C, for example,= create Fibers to handle the request. This approach is used in Swoole.

<= p>And this solution should be even slightly faster than in Swoole because t= he interaction will occur through memory copying within a single process.

If memory copying is to be avoided, then the web server can be integra= ted directly into the Reactor, making the web server itself run as a microt= ask. Since the memory will be allocated immediately in the correct thread, = there won=E2=80=99t even be a need to copy it, which in some cases might pr= ovide a performance boost. Or maybe not...

Ed.

--0000000000002c3cad062f4cff8e--