Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125075 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 46A041A00BD for ; Tue, 20 Aug 2024 21:54:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724190962; bh=O+BLNSb1Vyve+FWNswtl0jUFEfWL/rMB3Vm1udZlfZo=; h=Date:From:To:In-Reply-To:References:Subject:From; b=M1txRq0s/NMo8Ni9TWdcgXs15IPU5mHWEk8xxnVgVkw1av55LGH1GEj1vM3CQC3pc ab8BhuxWwPuh04XVBdFcMhk6q+bomgz//ccdclJ703mWSQMIvCELmBFG6Fetn4xC3m KGhvojs49nDfaXalyOSwORBPfuQ8PK130TrGThkJd+w5+mvZrtxlhEdkZW+x0Mx7bR 9mrbSvduxACRlWKOdiuHDup2yrV8Ju9k9UCXOJiftLD7pAeWyW15hvPXyj+1c4Q0/x QFFYJJ96sXj/lCPHIWkrCCHWqK1wnlijZXpc/Sh1yawyQPlFLShhv3n3jGh8Zj+NKs QKH9JfLdy13Sw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 33FC8180062 for ; Tue, 20 Aug 2024 21:56:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh5-smtp.messagingengine.com (fhigh5-smtp.messagingengine.com [103.168.172.156]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 20 Aug 2024 21:56:00 +0000 (UTC) Received: from phl-compute-02.internal (phl-compute-02.nyi.internal [10.202.2.42]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 81118114D725 for ; Tue, 20 Aug 2024 17:54:10 -0400 (EDT) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-02.internal (MEProxy); Tue, 20 Aug 2024 17:54:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1724190850; x=1724277250; bh=oFlYQ2Il5b eadiJCn08gTiUobgjtw4VPEvHETHsxd6w=; b=rOE1Udk04/KDAhUvyakctlbdyw yoxmzbZ6ZNZCYof3L+UeohWoqKy9ntuMrtUZXZA6WQzE/CM/w4CaKt06o2OQFYU7 D6miEuT7VYZFEG4d8S4OS1vk+5Fnuv0m6HvBs+TCZBXIWKz0PxmKf9j+g2JvBQup mEEufxHhQHrSKgZV4+vONyzfm/A/dsPJ4/Zu+OTeWSwePFRgJAUdCEgyjWbPMwgc zkqOifZv0bx/9OM0waBJMZoO9RAqb68OstdAVenniuN7vcyMU0IqysAB8JPOJ1yz oJMSMPn5UNOKIl9U/5gCEBwP9q1u2nEuz+zHVsYaCNq1YaRGVg9EHgwqKhig== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1724190850; x=1724277250; bh=oFlYQ2Il5beadiJCn08gTiUobgjt w4VPEvHETHsxd6w=; b=AcAGyCLyCZgSWhXn3zqXEBoCx3vWHs2EV4M4hXQ6Tbi6 SZ8vdu98zY/QmZM2inqHYwBFiZUDIYKsJs19RUbYQk7v99E0T2lo1ocGz44bt9BB k4DtfpiqSUob49P7GQv1t7cZpe+Lc7hbSv+Gt4R8Mgk8j9r6iGeLV0u7hKDu7v90 muwsO4C0Tn2xSkVdo4zX2m8t+H/sBleBmHZLNpe80G55Uv+Yr3LOT/Brzm1SNzr8 GdA4YDySj3AtkZnYZ6J64oRSTWb3ixXDkT7m1f8I2QOKghGxTG/KC+wJAxJ0XbyB v4yaIub43QH8eBqFMSbXm2zf+KMONiIfEiPza92VKQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddujedgtdegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefoggffhf fvkfgjfhfutgesrgdtreerredtjeenucfhrhhomhepfdftohgsucfnrghnuggvrhhsfdcu oehrohgssegsohhtthhlvggurdgtohguvghsqeenucggtffrrghtthgvrhhnpedtueejtd ethfeulefhtdelieduteelffdtudelheffgedtieehhfelieejgfevgeenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrohgssegsohhtthhlvg gurdgtohguvghspdhnsggprhgtphhtthhopedupdhmohguvgepshhmthhpohhuthdprhgt phhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id AAAAE15A005E; Tue, 20 Aug 2024 17:54:08 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Tue, 20 Aug 2024 23:53:48 +0200 To: internals@lists.php.net Message-ID: In-Reply-To: <00ee5318-329c-4a85-a2cd-1fc7050103ba@app.fastmail.com> References: <2716f729-4008-4f75-8412-861d8960b746@app.fastmail.com> <26338153-6d16-456a-81bf-8231bdaf1b79@app.fastmail.com> <6197f6e1-d123-41e1-87c8-887c6508bfa2@rwec.co.uk> <97d993ee-c558-43a1-a36a-8e06aa2d829a@app.fastmail.com> <1E9FCFA6-4FAD-4F47-9FC6-6AA8F2FD6BBF@rwec.co.uk> <00ee5318-329c-4a85-a2cd-1fc7050103ba@app.fastmail.com> Subject: Re: [PHP-DEV] function autoloading v4 RFC Content-Type: multipart/alternative; boundary=4bf74522a7ae44dc89a5800a4a1fdaac From: rob@bottled.codes ("Rob Landers") --4bf74522a7ae44dc89a5800a4a1fdaac Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Tue, Aug 20, 2024, at 18:07, Rob Landers wrote: > On Tue, Aug 20, 2024, at 08:50, Rowan Tommins [IMSoP] wrote: >>=20 >>=20 >> On 20 August 2024 00:21:22 BST, Rob Landers wrote: >> > >> >I assume you are worried about something like this passing test? >> > >> >--TEST-- >> >show called only once >> >--FILE-- >> >> > >> >namespace test; >> > >> >spl_autoload_register(function($name) { >> > echo "name=3D$name\n"; >> >}, true, false, SPL_AUTOLOAD_FUNCTION); >> > >> >echo strlen('foo'); >> >echo strlen('bar'); >> >echo strlen('baz'); >> >?> >> >--EXPECT-- >> >name=3Dtest\strlen >> >333 >> > >> >In my RFC, I mention it is called exactly once. >>=20 >>=20 >> I haven't looked at the PR, only the RFC, and I did not see this very= important detail explained anywhere. The only thing I can see is this r= ather ambiguous sentence: >>=20 >> > The function autoloader will not be called again.=20 >>=20 >> That could mean not called again for the current call (compared with = proposals that call it a second time with the unequalled name); it could= mean not called again for the current line of code (based on the curren= t caching behaviour); or never called again for that combination of name= space and name; or possibly, never called again for that combination of = namespace, name, and callback function. >>=20 >> That's not a small detail of the implementation, it's a really fundam= ental difference from previous proposals.=20 >>=20 >> So I would like to repeat my first response to your RFC: that it shou= ld sound more time explaining your approach to the multiple lookup probl= em. >>=20 >> Regards, >> Rowan Tommins >> [IMSoP] >>=20 >=20 > Thanks Rowan, >=20 > That's a fair critique. >=20 > I expect some of the wording will be more clear once I write out the d= ocumentation -- even if it isn't used directly, I tend to write out docu= mentation to force myself to reconcile the code with the plan, find logi= c bugs, perform larger scale tests, and create tests to verify assertion= s in the documentation. From there, I'll update the plan or code to get = everything to match and spend some time on clarity. It's the hardest par= t, IMHO, as it requires diligently ensuring everything is correct. In ot= her words, writing the documentation makes it feel like a "real thing" a= nd it triggers what small amount of perfectionism I have. >=20 > =E2=80=94 Rob I have an experimental library that I use for testing these kinds of thi= ngs. There are aspects of it that I could work with to make use of funct= ion autoloading. Thus, I did so and benchmarked the performance of unit = tests. The unit testing library makes a ton of "unqualified function cal= ls". I spent some time working on two autoloaders: 1. A naive autoloader: parses out the file to load, checks if it exists= , and then requires the file. 2. An optimized autoloader: only cares about the namespace it has regis= tered. All others are an instant return. In the "vanilla" case, I was mostly concerned with variation. I wanted a= statistically significant result, so once I got my system into a stable= state and I was no longer seeing any variance, I started benchmarking.=20 For the naive autoloader, I saw a performance degradation of about 6% an= d lots of variability. This is probably due to the "file_exists" check b= eing done every time an unqualified name was called. However, for the optimized autoloader, I ended up with less variability = (=F0=9F=A4=94) than the vanilla approach and absolutely no measurable pe= rformance degradation. Now, time to try this on a larger scale... WordPress. It's pretty much t= he only large codebase I know of that makes use of tons of functions. =E2=80=94 Rob --4bf74522a7ae44dc89a5800a4a1fdaac Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable


On Tue, Aug 20, 2024, at 18:07, Rob Landers wrote= :
On Tue, A= ug 20, 2024, at 08:50, Rowan Tommins [IMSoP] wrote:


On 20 August 2024 00:21:22 BST, Rob Landers <rob@bottled.codes> wrote:
>
>I assume you are worried about something like this passing = test?
>
>--TEST--
>sh= ow called only once
>--FILE--
><?ph= p
>
>namespace test;
>= ;
>spl_autoload_register(function($name) {
>    echo "name=3D$name\n";
>}, tru= e, false, SPL_AUTOLOAD_FUNCTION);
>
>e= cho strlen('foo');
>echo strlen('bar');
&= gt;echo strlen('baz');
>?>
>--EXPEC= T--
>name=3Dtest\strlen
>333
=
>
>In my RFC, I mention it is called exactly on= ce.


I haven't looked at the = PR, only the RFC, and I did not see this very important detail explained= anywhere. The only thing I can see is this rather ambiguous sentence:

>  The function autoloader will not = be called again. 

That could mean not = called again for the current call (compared with proposals that call it = a second time with the unequalled name); it could mean not called again = for the current line of code (based on the current caching behaviour); o= r never called again for that combination of namespace and name; or poss= ibly, never called again for that combination of namespace, name, and ca= llback function.

That's not a small detail = of the implementation, it's a really fundamental difference from previou= s proposals. 

So I would like to repea= t my first response to your RFC: that it should sound more time explaini= ng your approach to the multiple lookup problem.

Regards,
Rowan Tommins
[IMSoP]


Thanks Rowan,

That's a fair critique.

I expect some of the wording will be more clear once I write out the d= ocumentation -- even if it isn't used directly, I tend to write out docu= mentation to force myself to reconcile the code with the plan, find logi= c bugs, perform larger scale tests, and create tests to verify assertion= s in the documentation. From there, I'll update the plan or code to get = everything to match and spend some time on clarity. It's the hardest par= t, IMHO, as it requires diligently ensuring everything is correct. In ot= her words, writing the documentation makes it feel like a "real thing" a= nd it triggers what small amount of perfectionism I have.
=
=E2=80=94 Rob

I have an experimental library that I use for test= ing these kinds of things. There are aspects of it that I could work wit= h to make use of function autoloading. Thus, I did so and benchmarked th= e performance of unit tests. The unit testing library makes a ton of "un= qualified function calls".

I spent some ti= me working on two autoloaders:
  1. A naive autoloader: pars= es out the file to load, checks if it exists, and then requires the file= .
  2. An optimized autoloader: only cares about the namespace it= has registered. All others are an instant return.
In = the "vanilla" case, I was mostly concerned with variation. I wanted a st= atistically significant result, so once I got my system into a stable st= ate and I was no longer seeing any variance, I started benchmarking.

For the naive autoloader, I saw a performance= degradation of about 6% and lots of variability. This is probably due t= o the "file_exists" check being done every time an unqualified name was = called.

However, for the optimized autoload= er, I ended up with less variability (=F0=9F=A4=94) than the vanilla app= roach and absolutely no measurable performance degradation.

Now, time to try this on a larger scale... WordPress. I= t's pretty much the only large codebase I know of that makes use of tons= of functions.

=E2=80=94 Ro= b
--4bf74522a7ae44dc89a5800a4a1fdaac--