Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110684 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 38480 invoked from network); 19 Jun 2020 14:40:17 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Jun 2020 14:40:17 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6241F1804C2 for ; Fri, 19 Jun 2020 06:26:27 -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=-0.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS 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-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.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 ; Fri, 19 Jun 2020 06:26:26 -0700 (PDT) Received: by mail-lj1-f178.google.com with SMTP id x18so11479243lji.1 for ; Fri, 19 Jun 2020 06:26:26 -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; bh=Ak0I36gvfZIE/dH/hD005KXOtoejiqe5qcaqDRPcPdI=; b=Fud0m6XWZK/b4f8D0YpJk6vEvIkGE62X3l7ogPoUPLmFmEMMrTGrnds957azYlaQO3 VXI6Jjyq9LRN3G/zqI1wEMkauc+oodnFj2ctpue/iLj0sG6xGXqT5/7k+dKYXiw+Rvbq fVgf9gBIWY7oBxMtaURIYs8Hn12g4zvrggI507pXv0nhOyjWkTnSRLtKTt+fi5G7y2Wh nWG9k7NqzTtet+j/t2oZ7dSeFH/jBBgkbAdfisf47a804AITRAWNSyPO7mF26znojWc7 wZj+EUnDHhISu2xbYL8K8Ph1mWur7iN9So8IBiErZYJR8NHMvyNC4my/JkJhor1ECX4A Zntg== 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; bh=Ak0I36gvfZIE/dH/hD005KXOtoejiqe5qcaqDRPcPdI=; b=nvMVLRMTfANLj3vXMvaj2Cuasiq12HdPcZZUItygRPanI5EjnwTYugrL9np1iyClqQ DEZu+3Spk7XEyvdk/9994uUGKRr/F8WCP50DB0g6I4uzRl/SUpPztwgPOJ8Xpzi/fM1c jKjgg0ppIcdbwv+u2+Vw022EZCqXV1p/9Nr6vB+WncdA88fi0Lu63VYqCPyXu2bxRenA B6ZIOzrl3OJblrvNIip/txjl2JMyTQarNJeKuc+ne/Ih/Oj30Etzp+WjS3SXt/GFTvT6 eCZ2EBQ+uy/o+9NQDxETMCwMVOPTvqbpTY4Buk9+NYxiLzG1V8XMK7VBxOvFr9WS52WU jLrw== X-Gm-Message-State: AOAM530gW5JA4Fz7QPmEWoE63ypFQQ+mcXm5fhmnt1ZSG85XBE/fCoR0 M2mlWuQhUhidvtsa2G8TXW8ohgtuu4UW2haUZtw= X-Google-Smtp-Source: ABdhPJzzl3tRBYSql7hzeBne1t+zkGSxUe4mXl4fz+dSCS1ekqALqV3XaXs/aeVmAofjFySHFNPNlBIdbLMcPuP7rrk= X-Received: by 2002:a2e:b550:: with SMTP id a16mr1963558ljn.345.1592573185368; Fri, 19 Jun 2020 06:26:25 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 19 Jun 2020 15:26:09 +0200 Message-ID: To: Nicolas Grekas Cc: PHP Internals List Content-Type: multipart/alternative; boundary="000000000000fe252f05a86fd649" Subject: Re: [PHP-DEV] Resolve fallback-to-root-namespace in preloaded implementations From: nikita.ppv@gmail.com (Nikita Popov) --000000000000fe252f05a86fd649 Content-Type: text/plain; charset="UTF-8" On Thu, Apr 23, 2020 at 6:59 PM Nicolas Grekas wrote: > Hello, > > with preloading and Composer, we don't need anymore to consider autoloading > for functions and/or constants. The reason is that basically Composer is > already doing a great job at loading functions: just give it a list of > files and it will ensure they are included all the time. Actually, Composer > is just an example, all similar "require all the time" strategies work. > > The drawback of this approach used to be that requiring a bunch of > (potentially unused) files could be costly. But now that we have > preloading, this cost is zero. As such, autoloading functions/constants > would serve no purpose. > > Then, we periodically have discussions about the rules for namespace > resolution of functions/constants. The fallback-to-root-namespace has no > measurable performance overhead - the cache is very effective. Yet, Nikita > has stated a few times that knowing the type of the arguments of the > function being called helps the engine a bit. With JIT, this might be > (/become) more important (is that correct, Dmitry and/or Nikita?) > > I'm thus wondering: could we resolve the fallback-to-root-namespace rule at > preload time, for all preloaded implementations? For runtime-loaded code, > we would keep the current behavior. > > In practice, this means that during development (when preloading is not > used), we would preserve all the hackability that the rule provides (PHP > being a hackable engine is a big PRO, here, this can help e.g. testing a > lot). The fallback-to-root-namespace is a wise pragmatic rule that serves > the language well IMHO. But in prod, in full-perf mode (aka when preloading > is enabled), this proposal would pave the way for better performance with > JIT, if confirmed. > > WDYT? > > Nicolas > > PS: I fear I would be unable to implement anything related to this proposal > so I'm just sharing the idea to see if it could be interesting. > Hey Nicolas, I think this is something we should consider. Maybe not as default behavior, but at least under an ini setting. Basically, any unqualified call would get resolved to a global call or a namespaced call based on which functions are declarated at preloading time. I see one potential problem. If you have something like namespace Foo; if (true) { function strlen($x) {} } strlen("foo"); then depending on how the preloading is performed, PHP will not be aware of the "Foo\strlen" function. Specifically if opcache_compile_file() preloading is used, because it does not execute code. If "require" based preloading is used, this is not a problem. Regards, Nikita --000000000000fe252f05a86fd649--