Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85711 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29480 invoked from network); 3 Apr 2015 16:54:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Apr 2015 16:54:57 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.170 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.170 mail-wi0-f170.google.com Received: from [209.85.212.170] ([209.85.212.170:34150] helo=mail-wi0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D2/A0-23347-0E5CE155 for ; Fri, 03 Apr 2015 11:54:57 -0500 Received: by widjs5 with SMTP id js5so29636490wid.1 for ; Fri, 03 Apr 2015 09:54:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=user-agent:in-reply-to:references:mime-version :content-transfer-encoding:content-type:subject:from:date:to :message-id; bh=tsdCMfO429pZArG7U0bn8deCGqxniHsFfBivxnILliM=; b=PvHJZccyAk4WITZRT/3OuxSmP5c9Lcl1R6J6E+kJRpH0mKW0R+YSaNjtAWPtvyGpVF U2c7OPXjV4Lm8Ivqp1IncBtcmBFe4L0cASXzigrY1Km1of00u94ReygdNEoHHjV+8Cfb tEUgxoObKdTtUXvDy0NP2BShQtq2/bi3YKwvtqxxz+FZAtWoiPh0wnyltAtb4IcB4iT/ WhHlEUFpTJ5082vUCMDTWyByrYZIUPtoTAQ6JIyyVc4q3sqPmUKqfv9zHGP/m4lVHmvm FlhLZwx4mNm0XI8qwSMamMu9o3yK1w2wRw1XZQLgCsQrqcDpGrSgv1cQVGud1IA7Tkej HQ9A== X-Received: by 10.180.81.104 with SMTP id z8mr35804584wix.23.1428080094438; Fri, 03 Apr 2015 09:54:54 -0700 (PDT) Received: from [192.168.0.2] (cpc68956-brig15-2-0-cust215.3-3.cable.virginm.net. [82.6.24.216]) by mx.google.com with ESMTPSA id bp1sm12211688wjb.31.2015.04.03.09.54.53 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 03 Apr 2015 09:54:53 -0700 (PDT) User-Agent: K-9 Mail for Android In-Reply-To: <551B15DF.5090105@hristov.com> References: <551AAB20.6060100@luni.fr> <551AB705.5040001@hristov.com> <551ABCAF.4070008@gmail.com> <551B025C.6010702@hristov.com> <19D697AD-8FC9-4A49-A7B5-3577ED251830@gmail.com> <551B15DF.5090105@hristov.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Date: Fri, 03 Apr 2015 17:24:20 +0100 To: Andrey Hristov ,internals@lists.php.net Message-ID: <6603DFCA-8C2F-41CB-B309-F3D3A6BE73F2@gmail.com> Subject: Re: [PHP-DEV] Re: HTTP/2 and Websocket support in 7.x versions From: rowan.collins@gmail.com (Rowan Collins) On 31 March 2015 22:47:11 GMT+01:00, Andrey Hristov wrote: >On 1.04.2015 00:31, Rowan Collins wrote: >> On 31 March 2015 21:23:56 GMT+01:00, Andrey Hristov >wrote: >>> So, if Zend can be optimized to quickly clean the execution >>> environment, >>> and easily switch between them, we can have a giant leap towards >>> concurrent non-blockable PHP. The idea is simple - the Zend >environment >>> >>> should be some structure, and TSRM needs implementation not using >TLS, >>> in this case. The MySQL Server used to bind a connection to a thread >>> but >>> since years these are decoupled and with the right plugin you can >have >>> 100 threads serving many times more connections because thread >>> switching >>> is an expensive task. This ain't rocket science. >> >> You make it sound so simple, but the fact that an environment is set >up and torn down for each request is fundamental to the whole language, >not just a detail of the engine. >> >> If all you're doing is making that setup and teardown quicker, I >don't see how you're getting any closer to asynchronous code. FPM could >do all sorts of magic with its memory management, but it wouldn't help >someone write a WebSocket server. > >being able to serve more than 1 request in a thread by not using TLS >allows you to lower the number of threads used, significantly. On top >of >that by adding coroutines which run on a thread pool with fast setup >and >teardown give you the notion of parallel execution and because data is >exchanged with the coroutines only in serialized way, not by sharing >it, >a bunch of problems related to concurrency won't happen. Add promises >to >this soup together with non-blocking APIs (this won't happen overnight) > >and everything fits. > >> Maybe I'm missing something, but I can't picture how you'd have a >meaningfully event-based SAPI that looked just like a single-request >one to the user. > >I don't think that the SAPI needs to change. The SAPI doesn't mandate >processes, threads or whatever else primitives. It's a way to >(de)initialize module/request. The SAPI needs to change to have coroutines as something that can be allocated on an arbitrary thread pool. PHP contains a lot of things which imply global state (I came up with a list in a previous thread) and those are what I mean by setup and teardown. However fast you make them, they have to happen exactly once per userland script execution. In an event-based environment, you either have to not use any such global state (which makes for a very different language), or it has to be shared between all your lightweight workers, in which case those workers can see each other at the userland level. You can implement this in userland right now, using the CLI SAPI as the container of global state, and a co-operative multi-tasking scheduler built with clever use of "yield". A scalable and efficient version of that would be a new SAPI, and would have to make some tough choices about how existing features behaved, or if they were allowed at all. Regards, -- Rowan Collins [IMSoP]