Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47756 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81793 invoked from network); 2 Apr 2010 23:50:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Apr 2010 23:50:48 -0000 Authentication-Results: pb1.pair.com header.from=stas@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=stas@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.185 as permitted sender) X-PHP-List-Original-Sender: stas@zend.com X-Host-Fingerprint: 212.25.124.185 il-mr1.zend.com Received: from [212.25.124.185] ([212.25.124.185:56574] helo=il-mr1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 02/74-57677-6D286BB4 for ; Fri, 02 Apr 2010 18:50:47 -0500 Received: from us-gw1.zend.com (unknown [192.168.16.5]) by il-mr1.zend.com (Postfix) with ESMTP id 7996450504 for ; Sat, 3 Apr 2010 02:30:31 +0300 (IDT) Received: from [192.168.16.93] ([192.168.16.93]) by us-gw1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 2 Apr 2010 16:50:41 -0700 Message-ID: <4BB682D2.20104@zend.com> Date: Fri, 02 Apr 2010 16:50:42 -0700 Organization: Zend Technologies User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.9) Gecko/20100317 Lightning/1.0b1 Thunderbird/3.0.4 MIME-Version: 1.0 To: internals@lists.php.net CC: 'Andi Gutmans' References: <1941231697.20100401163215@gmail.com> <698DE66518E7CA45812BD18E807866CE03FA7EFF@us-ex1.zend.net> In-Reply-To: <698DE66518E7CA45812BD18E807866CE03FA7EFF@us-ex1.zend.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 02 Apr 2010 23:50:41.0618 (UTC) FILETIME=[4D9CAB20:01CAD2BF] Subject: Re: [PHP-DEV] php and multithreading (additional arguments) From: stas@zend.com (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 quite new development paradigm though. Imagine you have big application, say, using some Big Framework, that needs to do some mysql queries in parallel. Now what happens is: 1. You can't really just start a thread and run a query whenever you wish to, because mysql connection is probably defined by configs that BF is managing, so you'd have to either create a separate "query server" thread which would keep the connection or open connection anew each time. 2. You can't use objects or anything more complex than an array between threads, since sharing objects means sharing classes and methods, which means sharing data stored there. 3. You still have problems with libraries keeping global state, and many do and even don't bother to tell you about it or provide any means to manage it (e.g. ICU). 4. The overhead of keeping whole set of globals per thread will still be there. Which btw means starting a thread would imply whole RINIT process, along with allocating globals, etc. which may not be as fast as you'd expect. I think it may be worth trying, but for that we need some good use-case and try to see how it would work out with this use-case. -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com