Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113032 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 6866 invoked from network); 31 Jan 2021 17:47:02 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 31 Jan 2021 17:47:02 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B49801804B4 for ; Sun, 31 Jan 2021 09:29:48 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-io1-f53.google.com (mail-io1-f53.google.com [209.85.166.53]) (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 ; Sun, 31 Jan 2021 09:29:47 -0800 (PST) Received: by mail-io1-f53.google.com with SMTP id u20so770715iot.9 for ; Sun, 31 Jan 2021 09:29:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datadoghq.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=cbqDCHxDdacjIWx9HCFhkxQahfHmoz96Qf+VUlgKXUU=; b=HYnkrCyfTFadApemov1JzjYoJQXKxOt8njEMdub4kyw+Z+Xu/xpRIhKGxg7xYx1mnw /Lyjuc7I+U6x5FtM/mkEMKrlEMWk6oUr4tu4X3j9hMJHJv6u8QCeQgkHJr4VQPbhdxU1 o048OQUIKhTdJZOXv+6aAqW4Co+cpEcFOw0kw= 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=cbqDCHxDdacjIWx9HCFhkxQahfHmoz96Qf+VUlgKXUU=; b=A3WEYHBUC0M4hwN92NSZBZ6HYVLHhrIRvw5GhRIUfB7VZBbnOtGQmmJiM4Us36tIZi e83nenQ6QT/OepKr0Lh10xQsKj9Q2rzRo3zxv9/rbv+9Ry7NoQDyObRomaRO/WCilNmJ TP73I4Pm89jVf9OQbwssi1YbRRsnjmsxOqhw8Fsih9KoYrOrpS2a27QKY5GewpWXymVp Gr1QiZ8XJOshI77jeqnSd1i2OpuJL7WqyJo/FemMiESJH2HK7jPN/VWwhxk2IxSeNy5x BnwlZ8tZiBoGR5QCOSxjFJGPZXproLuJ/AkStJox+VDYDN21fLquSuuDnikZ3aIUdBhg IKlQ== X-Gm-Message-State: AOAM530ts3wmKdzLPiZWwVdHzjarTFUyrIFNA2srL4+81Ld2fnn4zy/c h8o/CAY3JPwbWbYXtUvj8PxwyznhimbqBIKh94Z7gw== X-Google-Smtp-Source: ABdhPJyjJOHcfqWHrFDdpdDE+be5SCaVKiPryeg7XH1SvDoGhLkKBepzl9OUDA6oOQYFCA8tP8nLSiZmnPoP9Vz8JbI= X-Received: by 2002:a05:6638:329a:: with SMTP id f26mr11666803jav.12.1612114186624; Sun, 31 Jan 2021 09:29:46 -0800 (PST) MIME-Version: 1.0 References: <9BF046F2-4799-4CCD-A7F0-739A91C77E83@trowski.com> In-Reply-To: <9BF046F2-4799-4CCD-A7F0-739A91C77E83@trowski.com> Reply-To: Levi Morrison Date: Sun, 31 Jan 2021 10:29:36 -0700 Message-ID: To: Aaron Piotrowski Cc: Benjamin Eberlei , php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Fibers From: internals@lists.php.net ("Levi Morrison via internals") On Sat, Jan 23, 2021 at 12:11 PM Aaron Piotrowski wrote= : > > > > On Jan 18, 2021, at 8:59 AM, Benjamin Eberlei wro= te: > > > > Hi Aaron, > > > > this is a very interesting and welcome piece of functionality. I have g= one > > through the RFC a few times now, it have never thought about or worked = with > > fibers before, additional feedback will be forthcoming once I grasp the > > details more. > > > > From my POV the effects on other extensions are the most important fact= or, > > you already have a section with that for Xdebug, Parallel, and pcov. Bu= t > > how does this affect Profilers that manage their own stack of frames, > > either all function calls or specifically selected ones. I.e. xhprof, > > tideways, datadog, newrelic and so on. > > Hi Benjamin, > > Sorry for the bit of a delay in replying. I=E2=80=99ve been busy the last= few days. > > Profilers that manage their own stack of frames will have to be modified = to account for fibers. The extension currently provides an API to access th= e current fiber and uniquely identify each different fiber. > > The internal API for this will need further discussion amongst the rest o= f the internals contributors and hopefully the authors of those extensions.= I omitted any API for this from the RFC as it does not affect user code. > > > > > At the moment any PHP Profiler only has to manage a single stack of "op= en > > frames". With Fibers for each fiber a new stack must be opened. > > > > Does an extension know what the "active" fiber is so that from a > > zend_execute_data I know on which stack of open frames I need to push a= new > > frame? > > Four functions are currently provided for determining the current executi= ng fiber. > > ``` > zend_fiber *zend_get_root_fiber() > zend_fiber *zend_get_current_fiber() > zend_long zend_fiber_get_id(zend_fiber *fiber) > zend_long zend_fiber_get_current_id() > ``` > > These allow you to get the root and current fiber as well as the ID assoc= iated with the fiber. > The fiber ID is unique to the process and is never reused, so it can be u= sed to determine which open stack frame to push a frame. I think it would probably be advantageous to have an observer that alerts interested parties when the fiber switches. This way we can avoid querying the current fiber on every fcall.