Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-11 Thread speedy
Hello Moriyoshi, Monday, April 5, 2010, 5:57:38 PM, you wrote: While it is based on shared-nothing approach, some kinds of resources are shared across threads besides classes and functions that would have already been defined before the thread creation. Maybe it would not be so hard

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-05 Thread Moriyoshi Koizumi
I used to play with TSRM days ago and successfully implemented userland threading support using GNU Pth. It's just a proof of concept and I did it for fun. If interested, check out http://github.com/moriyoshi/php-src/tree/PHP_5_3-threading/ and read

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-05 Thread Alexey Zakhlestin
On 05.04.2010, at 13:46, Moriyoshi Koizumi wrote: I used to play with TSRM days ago and successfully implemented userland threading support using GNU Pth. It's just a proof of concept and I did it for fun. So these are share-nothing worker-threads, which can send results to master-thread

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-05 Thread Moriyoshi Koizumi
On Mon, Apr 5, 2010 at 7:17 PM, Alexey Zakhlestin indey...@gmail.com wrote: On 05.04.2010, at 13:46, Moriyoshi Koizumi wrote: I used to play with TSRM days ago and successfully implemented userland threading support using GNU Pth.  It's just a proof of concept and I did it for fun. So

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-05 Thread speedy
Hello Moriyoshi, Monday, April 5, 2010, 5:57:38 PM, you wrote: Is overhead of starting new thread large? The cost is almost the same as when spawning a new runtime instance on a threaded web server with TSRM enabled. If you'd pass a large data to the subthread, then the overhead should go

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-02 Thread Jille Timmermans
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

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-02 Thread Ferenc Kovacs
On Fri, Apr 2, 2010 at 1:04 AM, Dennis Hotson dennis.hot...@gmail.comwrote: I use pcntl_fork() for writing parallel multi-process applications and it works pretty well. Also, you can use shared memory queues to pass messages between processes (ie msg_get_queue()). I wrote a little proof of

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-02 Thread Ferenc Kovacs
On Thu, Apr 1, 2010 at 11:35 PM, Pierre Joye pierre@gmail.com wrote: On Thu, Apr 1, 2010 at 11:33 PM, Stanislav Malyshev s...@zend.com wrote: Hi! Eve Online in Stackless Python fmspy.org http://fmspy.org with stackless python etc. I don't know how python does it but PHP has a

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-02 Thread Lester Caine
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

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-02 Thread Ferenc Kovacs
On Fri, Apr 2, 2010 at 9:06 AM, Jille Timmermans ji...@quis.cx 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

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-02 Thread Ferenc Kovacs
On Fri, Apr 2, 2010 at 9:30 AM, Lester Caine les...@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

RE: [PHP-DEV] php and multithreading (additional arguments)

2010-04-02 Thread Jared Williams
-Original Message- From: Ferenc Kovacs [mailto:tyr...@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 les...@lsces.co.uk wrote: Jille

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-02 Thread Eric Stewart
On Fri, Apr 2, 2010 at 1:16 AM, Andi Gutmans a...@zend.com wrote: Hi, 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

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-02 Thread Stanislav Malyshev
Hi! 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. No shared data requires

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-01 Thread Rasmus Lerdorf
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

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-01 Thread speedy
Hello Rasmus, Thursday, April 1, 2010, 5:21:55 PM, you wrote: 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

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-01 Thread Rasmus Lerdorf
On 04/01/2010 09:03 AM, speedy wrote: Also, keep in mind that the web is slowly shifting towards real-time communication / streaming with emergence of Comet, HTML5 Web Sockets etc. There are already many web server implementations specialising in that, and PHP is _not_ their language of

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-01 Thread speedy
Hello Rasmus, Thursday, April 1, 2010, 6:16:21 PM, you wrote: In any sort of Web architecture native threading in PHP just doesn't make any sense. Imagine a real-time websockets/HTTP based server processing architecture with quick event passing from one connection to another with possibility

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-01 Thread Jonah H. Harris
On Thu, Apr 1, 2010 at 12:57 PM, speedy speedy.s...@gmail.com wrote: Now imagine a whole web server written in PHP (ie. nanoserv), say, using libevent as the network backend, running the above described real-time web implementation. Alternatively, you could perhaps even wire it into

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-01 Thread Brian Moon
Now imagine a whole web server written in PHP (ie. nanoserv), say, using libevent as the network backend, running the above described real-time web implementation. Alternatively, you could perhaps even wire it into worker/event model of apache/other servers instead of rolling your own. It sounds

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-01 Thread Stanislav Malyshev
Hi! 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

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-01 Thread Antony Dovgal
On 01.04.2010 22:38, Stanislav Malyshev wrote: If you do, how you control access to them? Hello locks and the whole can of worms! Most people that think they can program in threads actually are just pushing their luck until some complex interaction leaves their app malfunctioning in a

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-01 Thread Pierre Joye
are we talking about having a thread safe PHP or parallel-like features available in user land? The sooner needs some love to be actually true, while most of the issues come from external libs. The later makes little or no sense. On Thu, Apr 1, 2010 at 8:52 PM, Antony Dovgal t...@daylessday.org

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-01 Thread Antony Dovgal
On 01.04.2010 22:54, Pierre Joye wrote: are we talking about having a thread safe PHP or parallel-like features available in user land? The sooner needs some love to be actually true, while most of the issues come from external libs. The later makes little or no sense. We're talking about

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-01 Thread Lester Caine
Pierre Joye wrote: are we talking about having a thread safe PHP or parallel-like features available in user land? The sooner needs some love to be actually true, while most of the issues come from external libs. The later makes little or no sense. Something we agree on Pierre. The first

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-01 Thread Alexey Zakhlestin
On 01.04.2010, at 22:38, Stanislav Malyshev wrote: Hi! 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

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-01 Thread Ferenc Kovacs
Anyway, do we really have to tell people you don't need it when they believe that they do? Python has multithreading and it works reasonably good. People who know what they are doing can implement really brilliant solutions (think Tornado) Interesting thing here threads would require (at

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-01 Thread speedy
Hello Antony, Thursday, April 1, 2010, 8:52:13 PM, you wrote: Not to mention that a high-performance multi-threaded daemon written in PHP is a total nonsense - that's exactly the task C/C++ do much better/faster. I'd like to have easily written, decently performing multi-threaded daemon. And

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-01 Thread Stanislav Malyshev
Hi! Eve Online in Stackless Python fmspy.org http://fmspy.org with stackless python etc. I don't know how python does it but PHP has a lot of global context, and sharing this global context between threads, whatever they are (OS threads, user-space threads, etc.) would be massively complex

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-01 Thread Pierre Joye
On Thu, Apr 1, 2010 at 11:33 PM, Stanislav Malyshev s...@zend.com wrote: Hi! Eve Online in Stackless Python fmspy.org http://fmspy.org with stackless python etc. I don't know how python does it but PHP has a lot of global context, and sharing this global context between threads, whatever

Re: [PHP-DEV] php and multithreading (additional arguments)

2010-04-01 Thread Dennis Hotson
I use pcntl_fork() for writing parallel multi-process applications and it works pretty well. Also, you can use shared memory queues to pass messages between processes (ie msg_get_queue()). I wrote a little proof of concept library a while ago to demonstrate: http://github.com/dhotson/Phork It's

RE: [PHP-DEV] php and multithreading (additional arguments)

2010-04-01 Thread Andi Gutmans
Hi, 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