RE: [PHP-DEV] php and multithreading (additional arguments)
| From: | Jared Williams | Date: | Fri, 02 Apr 2010 13:59:56 +0000 |
| Subject: | RE: [PHP-DEV] php and multithreading (additional arguments) | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-47742@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Ferenc Kovacs [mailto:tyra3l@gmail.com]
> Sent: 02 April 2010 08:40
> To: Lester Caine
> Cc: PHP internals
> Subject: Re: [PHP-DEV] php and multithreading (additional arguments)
>
> On Fri, Apr 2, 2010 at 9:30 AM, Lester Caine
> <lester@lsces.co.uk> wrote:
>
> > Jille Timmermans wrote:
> >
> >> Op 2-4-2010 7:16, Andi Gutmans schreef
> >>
> >>> I think that if we were ever to implement threading we
> would be best
> >>> off to enable spawning worker threads that have their own
context
> >>> with no shared data (and therefore no requirement for
> locking). We
> >>> could then have a message passing API between the threads.
> >>> Advantages:
> >>> - Real multi-threading.
> >>> - Simple straightforward approach which doesn't require a
> comp. sci.
> >>> degree to use correctly.
> >>> - Very stable implementation.
> >>>
> >> That sounds like "I want threading; because it sounds cool!".
What
> >> are the advantages of this above multi-process?
> >> The systemcall-overhead for message passing?
> >>
> >
> > Actually Andi's outline forms a nice simple base for
> something practical.
> > It simply builds on the 'background' threading required to run
> > asynchronous operations while not creating a unmanageable
> mess. But I
> > still can't see any need to go beyond perhaps asynchronous
> SQL queries.
> >
> > Or asynchronous exec, or asynchronous(or at least timout aware)
> gethostbyaddr, see:
> http://bugs.php.net/bug.php?id=51306
> So any task, that require waiting on external resource could
> be executed in paralel.
> http://hu2.php.net/manual/en/mysqli.reap-async-query.php
> its a good thing, that you can async mysql execution with mysqlnd.
>
> Tyrael
>
Curl can execute in parallel with it's curl_multi_*() functions.
MemCached can retrieve multiple keys with MemCached::getDelayed*().
The problem is can't mix operations*, and have a single wait on them
all.
*Unless you completely rewrite the various protocols in PHP.
Jared