Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102469 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34008 invoked from network); 26 Jun 2018 20:36:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Jun 2018 20:36:23 -0000 Authentication-Results: pb1.pair.com header.from=me@kelunik.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=me@kelunik.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain kelunik.com from 85.215.255.24 cause and error) X-PHP-List-Original-Sender: me@kelunik.com X-Host-Fingerprint: 85.215.255.24 mo4-p00-ob.smtp.rzone.de Received: from [85.215.255.24] ([85.215.255.24:27894] helo=mo4-p00-ob.smtp.rzone.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 66/F4-01794-5C3A23B5 for ; Tue, 26 Jun 2018 16:36:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1530045379; s=strato-dkim-0002; d=kelunik.com; h=Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=Yuhz+oYB2MSN9tVlEASyP/cBn9QKlxFMqgK3iNeT1Qs=; b=VTwdlRRx8jCT5LMOgzqv2UvATW/OzWURd66kuqfcjY7DVr5QKDYGQIsfOUbS0UADiH rAnDqMTwpTmLi6TLBPGRZSRFX6ZcLtPzFZlA1WrzK+5465QTSoiKYsNXQ0QXXHXEOt7B AKvUxuqwLl8gA3Xzdz17mmM+aJs4YvQ7RJh3ZRc5eEZfuz6DNPY786hKRn+iFyHBVvrI BrxDJ8ttCfBxD9DsW/6AUOumOoNc0K5IqCJB9wyqw58NY6zlva9g5z7kUG7La9bwBHov XcLaYOTAhrprnmgVMgYvp4mTd0vy/uatI5E30a8Pv5K1ABeZ1AY9jQDjRpWFsO4CQjYM apIQ== X-RZG-AUTH: ":IWkkfkWkbvHsXQGmRYmUo9mlsGbEv0XHBzMIJSS+jKTzde5mDb8AaBUcZiAkcA==" X-RZG-CLASS-ID: mo00 Received: by mail-yb0-f178.google.com with SMTP id r3-v6so2905418ybo.4 for ; Tue, 26 Jun 2018 13:36:18 -0700 (PDT) X-Gm-Message-State: APt69E1P8pkL4PN8MyBvtRm7BfuLYSvDxlWW9WpTc3uRlrjzkE/ka73e 7AYHXzjjBn68F3JCm3SKXhVWlZ9XVA/VKX5F5QQ= X-Google-Smtp-Source: ADUXVKIFRasrYUH14TJYZXjKs+xW1+qdlTcftS9hMDeorTRDb6vlc6IvmJNVkGKjOcBXZd/Y2cZnVuPn7Jgvl8DcJPA= X-Received: by 2002:a25:7ac3:: with SMTP id v186-v6mr1640134ybc.374.1530045378292; Tue, 26 Jun 2018 13:36:18 -0700 (PDT) MIME-Version: 1.0 References: <9f5698a2-aef7-4bea-99a4-cd8b22c49150@email.android.com> In-Reply-To: <9f5698a2-aef7-4bea-99a4-cd8b22c49150@email.android.com> Date: Tue, 26 Jun 2018 22:36:07 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Dmitry Stogov Cc: Aaron Piotrowski , Zeev Suraski , PHP Internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] PHP 2^3 From: me@kelunik.com (Niklas Keller) Hey Dmitry, > > hi Aaron, > > > On Jun 25, 2018 10:49 PM, Aaron Piotrowski wrote: > > > On Jun 25, 2018, at 7:30 AM, Zeev Suraski wrote: > > > > > > 2. Better support long-running, async-based, microservices-focused exec= ution model. It's probably no secret that one of the key reasons Node is g= aining popularity is because it can handle a huge number of concurrent conn= ections issuing relatively lightweight requests very efficiently - which is= a good match for modern microservices based architectures. There are alre= ady several projects available for PHP that aim to provide similar function= ality - most notably ReactPHP and more recently Swoole. > > The main thing that is missing is that most of PHP's IO doesn't support= async execution. What I think we should do is add as much support for asy= nc IO as possible across the various extensions and streams - so that using= something like Swoole would become practical for more use cases. More spe= cifically - the goal would be to provide extension authors with mechanisms = that they can use to make their extensions/functions optionally asynchronou= s, without having to tackle the job entirely on their own. While we've don= e some research into this area, it requires a lot more research - but I'm c= autiously optimistic that it can be done. We would potentially want to use= libuv for this task, and potentially rewrite or otherwise refactor parts o= f the PHP streams system. > > > > Regarding async, are you referring to the Fiber extension? In my opinion,= fibers would be the best approach for async in PHP. After using async/awai= t in other languages, it doesn't offer a significant gain over what's alrea= dy possible in PHP with generator-based coroutines in Amp. Using the fiber = extension and a green-thread library that resumes fibers based on promise r= esolution [1], we've been able to write async code without the need for yie= ld or await [2], with async functions having proper return types (i.e. not = promise, but the type the promise would resolve to). Joel Wurtz has also pu= t together a PoC of using Doctrine asynchronously using the fiber extension= and Amp [3]. > > Febers/couroutines is one of the goals. > Another possible goal =E2=80=94 event-loop primitives for internal extens= ions (e.g. async DB queries) > I think, we don't need async/await keywords or promises implementation in= core > Anyway, as an expert in async PHP, you should tell us, what you really ne= ed from the PHP core... > I would be glad to hear your oppinion. > > Thanks. Dmitry. Fibers are the major feature we're looking forward to, because it allows async I/O in places that do not account for async, e.g. also re-using interfaces designed for sync applications. Apart from that, we want to avoid the boilerplate we currently have to write, i.e. Amp\call wrapping a generator function. We think that a methodless "Promise" / "Awaitable" type + fibers implemented with keywords are the preferred way over the current Fiber draft in the long run. Fibers allow for transparent async I/O, which means we could maybe transparently upgrade file_get_contents and others to use async I/O in future versions, but something like that obviously needs an event-loop in core. That said, it's definitely something we want to push to PHP 8, but nothing that has to be discussed in too much detail in this thread. Regards, Niklas