Re: php and multithreading (additional arguments)
| From: | Rasmus Lerdorf | Date: | Thu, 01 Apr 2010 15:21:55 +0000 |
| Subject: | Re: php and multithreading (additional arguments) | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-47702@lists.php.net to get a copy of this message | ||
On 04/01/2010 07:32 AM, speedy wrote:
> 1. Imagine that from time to time, some background processing takes 1
> second of CPU time - w/o multithreading, all your async operations,
> like accepting a connection to a socket, aio or others are basically
> stalled. So, async is a good approach, but does not work as a magic
> wand for all problem spaces. Alternatively, you could fork and then do the
> processing, but then the state syncing of the forked background processing
> results with the main thread requires a whole new protocol / switching to
> interprocess communication, which makes such developments unnecessarily
> hard. Threads exist for a _reason_ not only because they sound cool.
There are plenty of mechanisms/protocols for doing this. Gearman works
extremely well for managing out-of-band jobs like this, for example.
> 2. Without thread support, it is not possible to use multi-core processing
> paradigms directly from PHP - which means PHP relies on external frameworks for
> that feature, which, in a sense, makes it a non-general-purpose language.
> It _could become_ a general purpouse tool, if it had proper multi-threading
> support built-in.
PHP is not a general-purpose language and there are no plans to make it
one. Your OS provides scheduling and is responsible for making best use
of your multiple cores. With many concurrent web requests your multiple
cores should be put to good use.
-Rasmus