Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112580 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 22103 invoked from network); 21 Dec 2020 23:01:09 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 21 Dec 2020 23:01:09 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DA07C1804B1 for ; Mon, 21 Dec 2020 14:33:39 -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-Virus: No X-Envelope-From: Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) (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 ; Mon, 21 Dec 2020 14:33:39 -0800 (PST) Received: by mail-qk1-f179.google.com with SMTP id p14so10328834qke.6 for ; Mon, 21 Dec 2020 14:33:39 -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=GXPfQ3U0mKS5ev97ox/+6i90hu+kFd74I9wfEeu56A4=; b=m6dWkXVOKEMO+yvYxd76oWye7dzOtTbPbbRpSyCs9gJv02iEqB9ssd97//w0o3sKNr If8VcM6fBlMqpxG7x78fBVk1fzx5JmLGplgmfvmAAp4cuEieZn4WW3whz15uM1nzuGd4 /akz4u0bSlZ9QLaiUM6XqcV9vOKxoNfQzugBi6+Ci5XaDDM/wQrLbYOCTqXybaalOzoM eQiD7v+9HXPnEwQpZRuUP0gEUK0qVA48sajRoOoiXtxoOYl7SJSKXul8Ey4ZOvmCAQSO JuNx0QaR39Awor9P1s2N9+pbNLUjOzKaptqn7W4LLIZNTHjf0KfL5YcR0cmmuxqN6b00 DuTQ== 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=GXPfQ3U0mKS5ev97ox/+6i90hu+kFd74I9wfEeu56A4=; b=CHWGTRNldX8c+4ifgzyXuYAb4FTSDxhzKWN34C3E0FmB6RpCXDpzGCtadltfIFBmqF eCMLUDQLAZQaz356H+U8mYackjyU43NJGUhwM0uwsTHpN1yvZeNBISuhV9ub0ma2gPff y0A2pYFxHRZSGvw7c4Qf5XZwdi38s+Gx1zR+51tsdN+KcRgLORheqBSOEz1NBhXbiCGu KO8T1fukL0wJYl/iTIc3CWsGoHgVt5AUtGGUmRwkkadvTJyGY/KwDXAlfpa/7jr7CN17 NII1SBTaA/Cu8IksYnv5ao1U2leToPvxXAxf2GyybIonZid3W+R8LoZfaZ7VHjEwX8mJ Q8cg== X-Gm-Message-State: AOAM531V2IIg/OYGbWWgmahqIOSFUWv3vJFIgd0mVnXqRbLmBVcji+EZ DR5zQqVFZHCjtC4omZ5bqL0M8gdP+rRNsQvk X-Google-Smtp-Source: ABdhPJxtDk6reHg2lPRdt44FwMaJFtfgfAv3QInUI/TZV5EakQCebxIB2iSyYY2O4aMvgc5IEuxz6A== X-Received: by 2002:a37:a309:: with SMTP id m9mr18929528qke.477.1608590015544; Mon, 21 Dec 2020 14:33:35 -0800 (PST) Received: from [192.168.1.236] (c-24-98-254-8.hsd1.ga.comcast.net. [24.98.254.8]) by smtp.gmail.com with ESMTPSA id i3sm5036816qkd.119.2020.12.21.14.33.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Dec 2020 14:33:34 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) In-Reply-To: Date: Mon, 21 Dec 2020 17:33:33 -0500 Cc: php internals Content-Transfer-Encoding: quoted-printable Message-ID: References: To: Aaron Piotrowski X-Mailer: Apple Mail (2.3608.120.23.2.4) Subject: Re: [PHP-DEV] [RFC] Fibers From: mike@newclarity.net (Mike Schinkel) > On Dec 17, 2020, at 11:30 AM, Aaron Piotrowski = wrote: >=20 > Hello everyone! >=20 > I would like to introduce an RFC for adding full-stack fibers to PHP: = https://wiki.php.net/rfc/fibers >=20 > Fibers are primarily used to implement green-threads or coroutines for = asynchronous I/O. Fibers are similar to threads, except fibers exist = within a single thread and require cooperative scheduling of the fibers = by the process. Since fibers do not require a full CPU context switch, = they are lightweight and more performant than multi-processing or = threading for awaiting I/O. >=20 > An implementation as an extension is at = https://github.com/amphp/ext-fiber >=20 > Fibers are a complex feature. The RFC contains many examples and links = to code using fibers to help explain and demonstrate what is possible, = however I=E2=80=99m certain many more questions and concerns will arise. = Looking forward to feedback and discussion. >=20 This is interesting, and potentially very useful. I am curious about how you propose access to shared memory across = fibers? What will happen if two fibers try to update a $GLOBALS = variable at the same time? Or a property of the same object? How will = developers manage that? -Mike P.S. Have you considered concurrency functionality like in GoLang[1] = e.g. channels, where the mantra is "Do not communicate by sharing = memory; instead, share memory by communicating?" [1] = https://medium.com/@thejasbabu/concurrency-in-go-e4a61ec96491#:~:text=3DDo= %20not%20communicate%20by%20sharing,race%20conditions%2C%20memory%20manage= ment%20etc.