Re: PHP True Async RFC

From: Date: Fri, 07 Mar 2025 18:19:57 +0000
Subject: Re: PHP True Async RFC
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
>
> 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.


Thread (110 messages)

« previous php.internals (#126622) next »