Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47702 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2196 invoked from network); 1 Apr 2010 15:22:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Apr 2010 15:22:07 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lerdorf.com from 209.85.218.216 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 209.85.218.216 mail-bw0-f216.google.com Received: from [209.85.218.216] ([209.85.218.216:55903] helo=mail-bw0-f216.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F4/11-31062-E1AB4BB4 for ; Thu, 01 Apr 2010 10:22:07 -0500 Received: by bwz8 with SMTP id 8so934281bwz.23 for ; Thu, 01 Apr 2010 08:22:03 -0700 (PDT) Received: by 10.204.163.4 with SMTP id y4mr1463369bkx.98.1270135322175; Thu, 01 Apr 2010 08:22:02 -0700 (PDT) Received: from [192.168.200.22] (c-98-234-184-167.hsd1.ca.comcast.net [98.234.184.167]) by mx.google.com with ESMTPS id d5sm67954457bkd.13.2010.04.01.08.21.58 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 01 Apr 2010 08:21:59 -0700 (PDT) Message-ID: <4BB4BA13.2070706@lerdorf.com> Date: Thu, 01 Apr 2010 08:21:55 -0700 User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10pre) Gecko/20100330 Shredder/3.0.5pre MIME-Version: 1.0 To: PHP Developers Mailing List CC: speedy References: <1941231697.20100401163215@gmail.com> In-Reply-To: <1941231697.20100401163215@gmail.com> X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] php and multithreading (additional arguments) From: rasmus@lerdorf.com (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 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