Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108246 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 49421 invoked from network); 25 Jan 2020 23:53:45 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Jan 2020 23:53:45 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 41A02180504 for ; Sat, 25 Jan 2020 14:03:28 -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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 25 Jan 2020 14:03:27 -0800 (PST) Received: by mail-yb1-f178.google.com with SMTP id p129so2961081ybc.13 for ; Sat, 25 Jan 2020 14:03:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=FOmR23xGUO5ZGVoe9xjDG6HhoUkCaXr5kOd+zRI7SDc=; b=Xi+L0vMc5UBLCWZqK26+LyxH3tjCTmcxFnBfzS0GTjDo68kk1o4qJz1nlEz+zTjjBa +3cX5iICKb8u9PoF1YgabRT8sDPLnnuCvrR8jVxpvdqU3XXc45HYPEusk3louGDl7LIW qoPVtWn2H/i8pOAnFnnI0h+kKR2r90wyAe1tdvh/MvxFe/jiO6Ib8aI6grOUYcuaaP27 VNVui7WUJbIYmSYeGiLFgK/iCrtHgl8p+Io+LzTzpybHtbCN9ATW9BCs5XcgQuNMb5ws pQPQyAa9lP3huAe+G3uM8Jxe0g+aTEMos6DrGOdiOtFZEgNatdc1bBYVYXYUMg6mnNTB +OvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=FOmR23xGUO5ZGVoe9xjDG6HhoUkCaXr5kOd+zRI7SDc=; b=omOdZIIRgcq0EYMrmlAiRKaH0mgkMiwoUpe3n0jWT9ggz46OuVIQ19uD5ozvHf8uQL 1DDRm/AxWBeWhXe23wozU1OZfoZqV8fsvtUggPrfRk7agXE/M3geriKfLw1Z6oDFlj9t E8opzLEkzJf93M0d5aGD9CT8ugi9SKwKQdIg0CzBTrmdk0yJLH7rdxVHT7e9BlVF09wg wvAqHNEBscIdmFH3HMgIHnngygfCBOzkxS5A7/88zK1UXqA/2V0fx0SqJWZklksyk4Nb 27/cF2zwwWsArvAc9LEOMI9Nhm21ehQDUdOPaFJQU5to+/jaYJwZJTozzeIvZzDirQN2 1AKg== X-Gm-Message-State: APjAAAWEUzxFINkV6ttazZmUbuYXLw/glp4OJ3QXvANGwC9YXxidfrex gCe48gdISnV+YwPAkx9/ph/a9Q== X-Google-Smtp-Source: APXvYqwuW29DPcnyV6cGobFCSz7NmlpzziWRiJAh50f9yNoRlCUpEf1SjhOOcKlFXR5UaLsHJYrhvQ== X-Received: by 2002:a25:6645:: with SMTP id z5mr8078931ybm.121.1579989806671; Sat, 25 Jan 2020 14:03:26 -0800 (PST) Received: from ?IPv6:2601:c0:c680:5cc0:9c03:aa12:eab0:1f6b? ([2601:c0:c680:5cc0:9c03:aa12:eab0:1f6b]) by smtp.gmail.com with ESMTPSA id j184sm1244505ywa.39.2020.01.25.14.03.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Jan 2020 14:03:25 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) In-Reply-To: <44ba543d-b6eb-888b-9ed5-0f1e9d3b53b9@gmail.com> Date: Sat, 25 Jan 2020 17:03:25 -0500 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: <8E382251-AE41-4BD9-A5F8-135D11B9E10D@newclarity.net> References: <3ca6d665-1a4f-8f7a-c82a-2e899f2e8df1@gmail.com> <44ba543d-b6eb-888b-9ed5-0f1e9d3b53b9@gmail.com> To: Rowan Tommins , Robert Hickman X-Mailer: Apple Mail (2.3445.104.11) Subject: Re: [PHP-DEV] Add viable long running execution model to php 8 From: mike@newclarity.net (Mike Schinkel) On Jan 25, 2020, at 3:44 PM, Rowan Tommins = wrote: >=20 > On 25/01/2020 18:51, Robert Hickman wrote: >=20 >> Yes that is what I was thinking, for example there is a userspace = implementation >> 'Swoole' that works in the following way, ReactPHP is similar = although I won't >> include that example as well. >=20 >=20 > So trying to get concrete: the first "official" component we'd need = would be an outer event loop, mapping requests and responses to the = parameter and return values of userland callbacks. In principle, not too = difficult, although I'm sure there are plenty of devils in the details. >=20 >=20 >> In my mind right now, everything should be shareable within a single = process, >> as one could do in the Swoole example above, nothing stopping you = defining a >> global in that script that could cache data in-process. >>=20 >> NodeJS, Python (wsgi) and others work fine using this model and allow = sharing >> of data within the same process. Trying to limit it to only some = types of things >> would be more complex as each type of thing would end up having a = different >> programmatic interface. >=20 >=20 > I may be wrong, but I think this is where it gets complicated. It's = not that we'd want to deliberately have different things have different = behaviour between requests, it's just that we've got a bunch of existing = stuff built on the assumptions of the current architecture. >=20 > In a single-threaded event loop, you want as much as possible to be = asynchronous, which is why both Swoole and React have a lot of modules = for things like network requests, file I/O, databases, and general = asynchronous programming. >=20 > Other things just wouldn't exist if PHP hadn't been modelled as shared = nothing from the beginning. Would set_time_limit() still be global, and = abort the server after a fixed number of seconds? Or would it configure = the event loop somehow? >=20 > I think there'd need to be at least a roadmap for sorting out those = questions in the official distribution before it felt like a properly = supported part of the language. I'm not following the discussion 100% =E2=80=93 more like 85% =E2=80=94 = but it seems like what we might be saying is the need for a user-land = implementation of a long-running PHP request, one that does not timeout? If that is the case, could we consider allowing a PHP page to opt-in to = no timeout? These types of requests could then handle web sockets, etc. Then we could look to prior art with GoLang channels where they = "Communicate to share memory" and do not "Share memory to communicate." = IOW, add an API that allows a regular PHP page to communicate with a = long-running page. This would decouple and allow for better testing, = and hopefully fewer hard to track down bugs. Further, I would suggest the long running requests not be able to = generate output except when the ini setting display_errors is true to = ensure they are only used for communicating with regular "shared = nothing" pages and not used in place of shared-nothing pages? Would this not be a workable approach? -Mike=