[RFC] Autoloader Classmap

php.internals

Mark Randall

5 years ago
Hi Internals, 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 Mark Randall marandall@php.net

Mark Randall

5 years ago
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. The tl;dr: * Autoloading is one of the routines called most frequently in any request. * It's a very minor boost in autoloading performance, around 5% vs invoking a userland function. This will easily be swamped by any IO and invalidated entirely by preloading. * I expect 99.9999% of users will never know it exists, and it will instead just be an option for tools like composer that will provide a small transparent boost. * It provides a very minor benefit to debugging as you get to skip over the autoloading frames which so very often come up during a request.

Stephen Reay

5 years ago
> On 6 Apr 2021, at 05:05, Mark Randall <marandall@php.net> 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. > > The tl;dr: > > * Autoloading is one of the routines called most frequently in any request. > > * It's a very minor boost in autoloading performance, around 5% vs invoking a userland function. This will easily be swamped by any IO and invalidated entirely by preloading. > > * I expect 99.9999% of users will never know it exists, and it will instead just be an option for tools like composer that will provide a small transparent boost. > > * It provides a very minor benefit to debugging as you get to skip over the autoloading frames which so very often come up during a request. > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php >
Hi Mark, Just to clarify something - wouldn't the loader use ‘require’ behaviour, not ‘require_once’ behaviour? If you’re hitting the autoloader, that means the class in the file you’re about to load isn’t defined yet, which means the file hasn’t been loaded already. Using require_once you’d be doing a check if the file has loaded in a scenario where it would have never been loaded anyway. Cheers Stephen