Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113585 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 38153 invoked from network); 17 Mar 2021 06:55:39 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Mar 2021 06:55:39 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8A0471804E4 for ; Tue, 16 Mar 2021 23:49:36 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.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 ; Tue, 16 Mar 2021 23:49:36 -0700 (PDT) Received: by mail-pf1-f178.google.com with SMTP id y5so444042pfn.1 for ; Tue, 16 Mar 2021 23:49:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=yVG1GdldHilvOl77/pfzFPcB055Y2Qbs7UKCcGMLeHE=; b=DbC6N18LAwDmpp0zk5PtV8AGOhKxn/uPN50Vnat+8A4iV24d1adFAqPPGXDSofmYhk lJaAYKxDznR+Qst9NJnso72NCa4bkuk5xy5m9GQINm/4XBMUpUZHqShaftqsX6QI2MT8 WMyZp0oiKxXerqbeLudRJ/eiImgeS2dYax/s8vTqNkHiZvAtNmwDBGLJZBccOYT5V6+L HKein4XS8mPY1OaYBfxJN6RJgn/eP5yAKn28Pva4lduv5X/Q2EZCQEYR23KMzQb7V8rr o11pXgKQeCQ+5ZUH/mFO9h0QxN6nVP9lrL+QAq6oRQM+zss7qyo8qPO1MzmPNM/w5pXI 1dVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=yVG1GdldHilvOl77/pfzFPcB055Y2Qbs7UKCcGMLeHE=; b=SspO32PUrDROwf3uo87ZuJHk09Jkv57pb9Q40O+ZZ7OAa/cyP7Hc8YAYc0Wjpyyp1v lhArnyHvufHj0VOBQDEZoctUShhtrUiLHXCut+BnzeCjxnPjWMb/lsND0pPqtc0bcTQd UrpBUML76/q6aLTLnRkR9o8oDGsoEj/AyA6o7jmwUkQxz9ar83PD+qK7Akekpys9GZOJ j/JFYTayy+y444G7SXE1VDUA7GLq7BtpjQHaEUGL7txNVe8fxm6si4aPhk6oK2zXjoY1 RvNBQaCD7NRKsg/q8EvRbFppsiyZ+2Ag5ss0Dp6/SDxQNV3xhqnstEw49oG/8kn4DHKy nzAw== X-Gm-Message-State: AOAM530s5hI9jR83xpf8YybZ4nR0tcg8Xe9VcgzOgcUMZQSV1aUIYHdl ojvuUomeb//xN+uHyl+eiJfNFd1VFYUTswHe1/0= X-Google-Smtp-Source: ABdhPJwA4OU/xVXuMdZ0kgYpmJxHIBU8IYMpuAUAAL9D4HNTrHEHtJVaLn2xcd+x8kJOj/gsHWNnxQu5cVd2poeZLzg= X-Received: by 2002:a63:f202:: with SMTP id v2mr1433356pgh.24.1615963773292; Tue, 16 Mar 2021 23:49:33 -0700 (PDT) MIME-Version: 1.0 References: <70951423-5e77-c150-6dce-dd3c62f8dc8b@php.net> <0b994a60-7970-605b-1657-d6ee732690e5@gmx.de> <5C73A1DE-E563-4F69-B8C7-6506F81D7345@trowski.com> In-Reply-To: Date: Wed, 17 Mar 2021 06:49:22 +0000 Message-ID: To: Peter Stalman Cc: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [VOTE] Fibers From: joshdifabio@gmail.com (Josh Di Fabio) Hi Peter, Thanks for the feedback! On Wed, Mar 17, 2021 at 3:02 AM Peter Stalman wrote: > > On Tue., Mar. 16, 2021, 13:58 Josh Di Fabio, wrot= e: >> >> Fibers will not make those issues obvious at all. The issues I'm >> describing will only crop up spontaneously and under load. > > > Hi Josh, > > Is this really that big of a concern though? The issue will only be a pr= oblem if it's run inside an event loop/scheduler that the concerned library= is compatible with. In which case the developer should be well aware of w= hat is involved. Not exactly, no. As a library author, code you wrote without fibers in mind can become async. Imagine for a moment that you create a library, awesome-library-x, which uses a PSR logger internally. You will most certainly allow that logger to be injected into your library. Now imagine that some other developer uses awesome-library-x in their application, and injects it with a monolog logger that logs to some AWS service via the AWS SDK. In turn, that logger indirectly uses Guzzle, which adds fiber support. As a result, any functions in awesome-library-x which log something become asynchronous. Two changes made by two developers unrelated to awesome-library-x cause its code to be executed asynchronously. > Otherwise, if the library uses fibers internally it will have to resolve = them itself before continuing, no? If `capturePayment()` starts a fiber th= en execution will not get to `setTransactionId()`, until it completed or is= handed of to a scheduler (again, which the developer would be aware of. > > So I don't think developers will face this race condition, unless they ar= e using framework like amphp and reactphp. But that's already the same now= , so if it's an issue it's not a new one with this RFC. It is a new issue. Today, interruptible functions must include a `yield` statement, so they are explicitly interruptible. > Your average unaware developer can continue to happily use any libraries = they want without encountering any async issues. The calls from outside th= e library will still be blocking, as PHP will still be single threaded. > > Thanks, > Peter > > I feel like we're going round in circles a bit, and I don't want to drown everyone in emails, especially as we're out of the discussion period for this RFC. I will try to clarify my point and attempt to summarise the counterpoint to reduce noise. My opinion is that, in a world of multi-vendor applications and dependency injection, async can't safely be an implicit feature, it needs to be explicit. It should be noted that virtually all general purpose programming languages seem to take this view, including, for example, hacklang. The counter argument is: if you want to use fibers, you have to be sure that your entire codebase, *including all of the code you import from other vendors*, is written with fibers in mind (or is compatible by good fortune). But this will not be made explicit in the code. I think this is wishful thinking, and highly impractical. And finally, to clarify one other thing, the bugs I'm talking about are race conditions. You don't identify race conditions by executing code, you find race conditions by reading code. So all of the code has to be read in order to find them all, there is no shortcut. Most people won't actually do this however. Cheers