Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108247 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 53374 invoked from network); 26 Jan 2020 00:15:48 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 26 Jan 2020 00:15:48 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3EB231804AC for ; Sat, 25 Jan 2020 14:25:33 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS24940 116.202.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from outbound.soverin.net (outbound.soverin.net [116.202.65.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 25 Jan 2020 14:25:32 -0800 (PST) Received: from smtp.freedom.nl (unknown [10.10.3.36]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by outbound.soverin.net (Postfix) with ESMTPS id D87DE60959 for ; Sat, 25 Jan 2020 22:25:30 +0000 (UTC) Received: from smtp.freedom.nl (smtp.freedom.nl [116.202.65.211]) by soverin.net DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=freedom.nl; s=default; t=1579991125; bh=9QZql5LEO+UBT8BusoE33Syok4loHZiB7B5uCkEk37k=; h=Subject:To:References:From:Date:In-Reply-To:From; b=rsVrv35Lfb0DZuqFzaYjh3M/ztu45bbSId4jKczsmPfRKecUPn9qTCiU3pPv4u22U 72Wu6y8nRF13as3NXFq9HzciTkVzIWlM26gglCVjVYcpFsoa+F5Upva7f+FxlS35G1 z+5amM7viQPpDz+iWlb7AZkBW8sPpLHIRthv03p0= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=freedom.nl; s=default; t=1579991130; bh=9QZql5LEO+UBT8BusoE33Syok4loHZiB7B5uCkEk37k=; h=Subject:To:References:From:Date:In-Reply-To:From; b=heFKUaiAvAZz3hb6Mg7yjC1zOS6Oa8oMakMYsMevICGBYHbkocG2RHRAncVQHlZJf w5Qgpv9lo+AYCQTMzTbtMtfdTxF3yArToGzZaEr/gQbTs36+et1/z2uJOwYBe0dLP2 oQd0q2BtF1AQOeFW28Sb292ihL/k7zHlxIXagBuo= To: Robert Hickman , PHP internals References: Autocrypt: addr=d.h.j.takken@freedom.nl; keydata= xjMEXimHTRYJKwYBBAHaRw8BAQdAzvRUI24yOGvteVk9N6VKIt425fNgg0P1rvD2WQLGP+fN JERpayBUYWtrZW4gPGQuaC5qLnRha2tlbkBmcmVlZG9tLm5sPsKtBBMWCAA+FiEEvtrj9qG2 TA2YmjvLhef0X6cSlpAFAl4ph00CGwMFCQlmAYAFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AA IQkQhef0X6cSlpAWIQS+2uP2obZMDZiaO8uF5/RfpxKWkPywAQChh9Z1jSvitkT3sIipwMlk dnUlYY5Ue3lHBBhF6pQUOwD/XtEz/fsjvqE/GpjJhXpxNodwKjLhaUiFe9qRwwH/5QXOOARe KYdNEgorBgEEAZdVAQUBAQdAMNSCUI0PnOjjrFKZDAFRQzKLVDCINuFNgsXh0snmlUwDAQgH wpUEGBYIACYWIQS+2uP2obZMDZiaO8uF5/RfpxKWkAUCXimHTQIbDAUJCWYBgAAhCRCF5/Rf pxKWkBYhBL7a4/ahtkwNmJo7y4Xn9F+nEpaQEYUA/2mZ3uEN0JTRUZbxHGBMB4IhQw0cdIML FpFrTycqUCXCAQD5rWXomBWVD/DRHk7O3KjNsek9F1DEZgGeZ5pPmNF/Dg== Message-ID: Date: Sat, 25 Jan 2020 23:25:17 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US X-Virus-Scanned: clamav-milter 0.102.1 at c03mi01 X-Virus-Status: Clean Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Add viable long running execution model to php 8 From: d.h.j.takken@freedom.nl (Dik Takken) On 24-01-2020 10:29, Robert Hickman wrote: > PHP is pretty unusual in comparison to most web platforms nowadays as it > runs each request in an isolated process. Web development in other > languages is instead based around a long lived set of processes, which > serve multiple requests. The shared-nothing architecture of PHP is the very thing that makes it simple and robust for web development by default. I do a lot of Python web development as well and the fact that it implicitly shares state between handling multiple requests has bitten me more than once. The same is true for writing multi-threaded code. This is very tricky business in most programming languages. PHP extension 'parallel' by Joe Watkins leverages the shared-nothing architecture of PHP to make writing multi-threaded code simpler and more robust. Very clever. > That model has advantages in that it is very easy to cache data in process, > and should be simpler in theory to get good performance as all code can be > loaded into memory once during startup. Autoloading therefore goes away. Yes, getting better performance is easier but writing robust code becomes harder. > There are userland implementations like PHP-PM, but I think it good to have > an official way of running code in this way in php 8. I'm not sure what you mean by an 'official way'. What is the problem with using one of the userland implementations? One thing I can imagine PHP could offer in this area is exposing the existing internal mechanism to mark data as persistent. This mechanism is used by extensions to offer persistent network connections for instance. It could be used to implement a language feature to allow sharing specific state between requests in an explicit way. When using an event loop based framework everything is shared implicitly. Now suppose that we could declare a static variable like this: static persistent $var; When the request ends the PHP interpreter data is cleared to handle the next request. Only the data that is explicitly marked as persistent survives the request and is available in the next. This would allow retaining the current shared-nothing architecture while offering the means to break the rules in a well defined way. Regards, Dik Takken