Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126622 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 B39F91A00BC for ; Fri, 7 Mar 2025 18:20:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1741371456; bh=JBrvbhxM+cz/07zio7yXUGnkS0QGxDGjJ24opITpfnI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=gkD2rvTu5RpkJVpRiT3oJ3j5IZKtcWDOcoWYGzEetAZZrkgB/Hpb7jRiq5X/s8p22 fhuHbvGO79kTUGjnu8aNdJUF6vWEylSQAVLnTA5GS9MPYxg24K0WN0MiQFhJMLjQ7r b4OYSA+xWKyiaoz9SglONGdRmpZzrM7+NPk0DeeeDFszRlUNzaZojqrtW38JDPmJWl RaON0Mtojcqx7HfIOTydTZLMjclaVTYAfkJmIXG2aASMLziS2VdKDnQ8exYalE+RuW xqFldcNbncjrk8p6aBIZfl3clRdE/psCxSP4nWUfa9L5vbFXDB1Zhic7QXnbhKtnrb mN/l9RX1jV1vA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 56F9218038A for ; Fri, 7 Mar 2025 18:17:34 +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.5 required=5.0 tests=BAYES_05,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-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) (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, 7 Mar 2025 18:17:33 +0000 (UTC) Received: by mail-yb1-f172.google.com with SMTP id 3f1490d57ef6-e461015fbd4so1534201276.2 for ; Fri, 07 Mar 2025 10:20:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741371608; x=1741976408; 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=kigGz88gs1i0dAHrWJ2v/uqHtS6FB6ilauY/8dSqcpA=; b=X2xjyPlE86OY7HqmbDjrzHptG/k2+pdGbZhFdXp4cu5t35WDbitoGODszpVlL8gTdx It8K4GRfcdKWKkXuRejEFQ514asWhw0P+qP85vgRTglq7ZdJnBmW88lPU7+sscgn1e1K G1Ab8wJDpBBlkJvHA9k4umU32i7yDFswO4EOp4y029VVoJKSUTozCj+vQySG4m6Ay4vw yYQG0GKwJTxfPYG4WDhoWjMMosXVedj7dYgX48ulbW8KeQltfOTHwrt3YZIJEplxua+8 6kEmQVTu0EgnhZ9g2SQMg4DSpQmROwgn0M3UnQcBYk6zdVUmlCzGOLLPWlO5b+YH3nJP 0JJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741371608; x=1741976408; 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=kigGz88gs1i0dAHrWJ2v/uqHtS6FB6ilauY/8dSqcpA=; b=abZowlqS5VuX1oZaTiJcDDXWYvXtin+ce9dvjXEwaF6zTRFbZaBiEfpi9KuG5Wk7B8 LlrKJSu5TcdNp7VEuDC5u/SbjVcYvLefYArmCir7aG9EhFOHbRvaXEqpXJ6oj2Z9dtJm fU+QARHykF51NmWlnSx18U+cY+6208UUII2LwRhU4EpFcKODC0vqroCq5LA7ihRST5hA KikSVW97KOiQTSzDZ/pKY7bTY3qxGdx5GaKkRW+sKrRRIpCpJks028i411FPyIG2/YN3 ZGh8l/b2XcF58/8AgCx4UMqDSR2YjD9BZB+k9SO5y021IggilNtETp7MqhDzXTzYZAFN NQ2Q== X-Gm-Message-State: AOJu0YyZAU2bVB1Et1R9IA7H/rCN4w2KISx/oGi9cMNXHhmEjXcbX5eb prxVgOgxEFJLOtU08z/GfmlrS89rRUAhn4DJlABcsCu9IWYEm9viZa2seHlo+2jfdXMEB4b7j3b e8A5Bus9eFOd8JEERCMRS43bj6ya5I8rn2rw= X-Gm-Gg: ASbGncv832NNfEbkKwh1Y0wokBJMRIebV4YcE7OxEEiQR+0B0uWRV+UHGHM1lP/b6RA wK8YDMBj0NglT8t2U6X5iCZjRhasoA9GJHpe1AKDSFVoDtGFsaUH8ujisz4L9zjFOBztbC9rIsf 3jg0NqaplL+sWA9CUNvAHkLqk/9w== X-Google-Smtp-Source: AGHT+IFZFTzb6AQzQc6xN893Aj1cYbckHi/JJczOFZ44a767YZqfZh1DdQ+at9IKVg6N6X1ACgX2iHE5xfmYU6kKbHk= X-Received: by 2002:a05:6902:2301:b0:e60:79c0:5089 with SMTP id 3f1490d57ef6-e635c0f92b5mr5882484276.10.1741371608556; Fri, 07 Mar 2025 10:20:08 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <9964db8c-0ffe-43d5-8246-47fc76b07180@app.fastmail.com> <78a03dd0-fd4a-4f4a-ad8a-37e5704f06fc@app.fastmail.com> <23e162f6-54b0-4564-9d79-7b3bdc3d1ab5@rwec.co.uk> <36cee7e3-2ef8-4f96-a72e-e67a99e5f9bb@rwec.co.uk> <779046a0-7c70-45a9-82c4-7c31c502cec2@rwec.co.uk> <3a647368-706c-4d67-8dac-9f7d2557da35@app.fastmail.com> In-Reply-To: <3a647368-706c-4d67-8dac-9f7d2557da35@app.fastmail.com> Date: Fri, 7 Mar 2025 20:19:57 +0200 X-Gm-Features: AQ5f1Jr0P4H7bMTiTXgHM-4MKwHGZuOqAZwl_XWi_NzOc58L0G8sRlb9-YuhRPE Message-ID: Subject: Re: [PHP-DEV] PHP True Async RFC To: Rob Landers Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000267124062fc4ac03" From: edmond.ht@gmail.com (Edmond Dantes) --000000000000267124062fc4ac03 Content-Type: text/plain; charset="UTF-8" > > A SAPI is written in C (or at least, using > the C api's) and thus can do just about anything. If it wanted to, it could swap out > the global state when switching fibers. > Probably, it's possible. However, if I'm not mistaken, $_GET and $_POST are implemented as regular PHP arrays, so if they need to be adapted, they should be replaced with proxy objects. > > So, at a minimum, I would guess the engine needs to provide hooks that the SAPI can use to provide request contexts to the global state > Thus, the cost of coroutine switching increases. Coroutines can switch between each other multiple times during a single SQL query. If there are 10-20 such queries, the total number of switches can reach hundreds. Using the proxy pattern is the most common practice in this case. > > If fibers were to allow true concurrency, we would need many more primitives. > You mean true parallelism. If that happens, all existing PHP frameworks, libraries, and C extensions would have to be rewritten, sometimes almost from scratch. But it would most likely be a different language. Ed. --000000000000267124062fc4ac03 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
>
>=C2=A0A SAPI is written in C (or at least, using
> the C api's) and thu= s can do just about anything. If it wanted to, it could swap out
= > the global state= when switching fibers.
>

Probably, it's possible. However, if I&= #39;m not mistaken, $_GET and $_POST are implemen= ted as regular PHP arrays, so if they need to be adapted, they should be re= placed with proxy objects.=C2=A0=C2=A0

>
>=C2= =A0 So, at a minimum, I would guess the engine needs to provide hooks that the = SAPI can use to provide request contexts to the global state
>

Thus, the cost of coroutine switching increases. Coroutines= can switch between each other multiple times during a single SQL query. If= there are 10-20 such queries, the total number of switches can reach hundr= eds. Using the proxy pattern is the most common practice in this case.=C2= =A0=C2=A0

>
>=C2=A0If fibers were to allow true concurrency, w= e would need many more primitives.
>
You mean true p= arallelism. If that happens, all existing PHP frameworks, libraries, and C = extensions would have to be rewritten, sometimes almost from scratch.=C2=A0 But it would most likely be a different language.

= Ed.
--000000000000267124062fc4ac03--