Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113976 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 54635 invoked from network); 6 Apr 2021 08:02:55 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 Apr 2021 08:02:55 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8D8701804DF for ; Tue, 6 Apr 2021 01:01:51 -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,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-Virus: No X-Envelope-From: Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (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, 6 Apr 2021 01:01:50 -0700 (PDT) Received: by mail-ed1-f54.google.com with SMTP id f8so11373199edd.11 for ; Tue, 06 Apr 2021 01:01:50 -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=I16iLqsWjtViBETUZyqLE7Zd1t/ClI0pOkUTXehxoTk=; b=fbnEojH3LKOWsFG81Q7dPRgIzru0CPZoLn2l2/Bo9F3i6gRfKl2gaBhyq9hJzsEl6W vcNnalpLHDr5lCb35nSKovfiJarSNc6nWenb6GfL0/oi+UET/FjCItiL4+e42lg5TTEG 06y1iywTJJeWVP19NSd9LBMyI2GII8qFk3iP4rfhnU5qr7rrp5gbDVbtpnn4eNJx37WN lUK4C4y6MHhnifL5RzGrnoUg75d/yDvTYD5JcBqaeh7bZqRLe9k4p6DP30RNZL5LANn5 MlEpon/laN+wF6Bw+ehHoW7wy3znNOzZMum7Pk5xwcznfX5x+wuprNVwhGNth+aQx7ID zncQ== 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=I16iLqsWjtViBETUZyqLE7Zd1t/ClI0pOkUTXehxoTk=; b=jtPcgzD/OdzEa8+cpfeJj8rSnrocl4uJ/p19GfohurolOENe48+Jc8qJjHiSaxJ4/8 Cvgn10iVYuQ4CL3WxYtho3/H/m2IyUaGhQAgwUpg3kFub8fje7vK6ItGh/O3OcIxOah6 AhJ6AwokEMZe592HlVEh1st7NmWbF9kUTwQz6T8o/tAuYhNnq0Dm55m2QXR2qqOa7cvT n74kI7a11wkf5qZzUQMNgt2VfqYazvlyLXRffUYunaG8gBpKmBGpMVcT1EFZnLPaAyKl pL28ocw+CU3H025U5K97qePCE3lAVt66NY+5hfuwoIFNnfVCWkl4MlYiA3HCHl61mPZP LRvg== X-Gm-Message-State: AOAM531abReGlOFa/RQFOUuCmW6K6tXjRuQXM/lYAZyblujso3FkmqBE RzugSSq73wKySBUSm4h8uT3FN2xbDSQ64LR7xeMV2RKChNXTbA== X-Google-Smtp-Source: ABdhPJx1iAAJ266OMjJtSgIDV5Dq4DzI/Teqxb3HRSBLFEO8cRCN0LZMHerAPeq7a2U49BKJLCsv6oki/OWyKIk8q3w= X-Received: by 2002:a50:e887:: with SMTP id f7mr488688edn.107.1617696109477; Tue, 06 Apr 2021 01:01:49 -0700 (PDT) MIME-Version: 1.0 References: <606b8994.1c69fb81.dd253.1b68SMTPIN_ADDED_MISSING@mx.google.com> In-Reply-To: <606b8994.1c69fb81.dd253.1b68SMTPIN_ADDED_MISSING@mx.google.com> Date: Tue, 6 Apr 2021 11:01:33 +0300 Message-ID: To: Mark Randall Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000f5c1e805bf493942" Subject: Re: [PHP-DEV] Re: [RFC] Autoloader Classmap From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --000000000000f5c1e805bf493942 Content-Type: text/plain; charset="UTF-8" On Tue, Apr 6, 2021 at 1:05 AM Mark Randall wrote: > On 15/03/2021 17:41, Mark Randall wrote: > > I would like to propose the addition of a new mechanism of autoloading > > classes - a classmap that will be consulted prior to checking the > > spl_autoload_register'd callbacks. > > > > https://wiki.php.net/rfc/autoload_classmap > > Does anyone else have any more feedback on this? If not I plan on > opening voting in a couple of weeks or so. > - It's not clear from the RFC if the `spl_autoload_call` will use the classmap or not. I assume yes but maybe it's good to mention that. - There is a mention about another "independent RFC" but I can't seem to find any draft of it or other reference. Maybe add some more links and clarify when it is expected to be filled and by who. - It was previously discussed but it's still not clear why the key should be lowercase. - As far as I understand, when the class autoloading is triggered, the classname is available with it's requested case so that is not an issue. - It is inconsistent with how `autoload_register` callable works. - I would like to have things like autoload_set_classmap([ClassToBeLoaded::class => '/specific/path/for/class.php]) without adding an extra `strtolower` wrapping call. - Is there a performance benefit of having all classes with lowercase? - If a class autoloading is triggered with the wrong case (due to a typing error), I would very much like to fallback to classic autoloaders and fail so that I can possibly find the issue faster. - Related to"Trigger a TypeError if the key's associated value is not a string.", shouldn't we validate the value when setting up the function. Having a TypeError when autoloading happens signaling an invalid configuration sounds a bit weird. - Does the extra step to check the classmap also increase time if the class is not found? If most of the classes are loaded using classic autoloaders, will there be an impact from having some classes defined for the classmap autoloader? - How was the test that showed the 5% run? Was there any IO involved during the classloading? How was the opcache configured? There are some times mentioned there but it's not clear the unit of measure. - I understood that in real life the 5% is only out of the 0.1 - 1% that is classloading out of a script's runtime. That would mean an 0.005 to 0.05% performance increase. It's unclear to me how much of a script's time the autoloading takes. Maybe you can clear that out if you counted for a normal application run, like a hello world from symfony. I understand that there will be nothing visible but maybe it's good to mention that, just to have clear expectations. - Maybe you can give a sample code for when the autoload_set_classmap needs to be used from two different contexts/modules that are not aware about the others. I would expect something like: - `autoload_set_classmap(autoload_get_classmap() + $moduleClassMap)`, not overriding previously set map values, if duplicates Regards, Alex --000000000000f5c1e805bf493942--