[TYPO3-project-4-3] autoloader using SPL

Ingo Renner ingo at typo3.org
Mon Aug 4 17:42:53 CEST 2008


Dmitry Dulepov [typo3] wrote:

> You say that many includes is a problem. We mainly use require_once, so 
> files should be included more than once. I do not understand where the 
> problem comes from. 

this is the secondary problem: includes/requires are slow per se.

> Or do you mean that files are included and not used?

yes, this is the primary problem. We include lots of files without using 
them. So

1) we try to include same files more than once ... which slows down the 
system
2) we include stuff we do not use ... which slows down the system
3) the stuff that gets included but is not used must still be compiled 
... which slows down the system
4) the stuff that is compiled but isn't used still takes up memory ... 
which slows down the system

... and so on

>>> On the other hand many TYPO3 files always include files but use them 
>>> only in some cases. 
>>
>> That's exactly the problem.
> 
> Shouldn't we start reviewing those?

that's of course another job

>> This is not a blinf action as I described how I think it 
>> should/would/would work. In the worst case it's just as slow/fast as 
>> the  current way of including all files. In all other cases it's most 
>> likely going to be faster.
> 
> require_once(PATH_t3lib . 'class.t3lib_db.php');
> 
> vs
> 
> $path = Registry::search('t3lib_db');
> require_once($path);

well, t3lib_db is probably the worst example you could have picked for 
autoloading as it's really (except for some cases) required everytime.

rather think about t3lib_basicfilefunc f.e.

Other than that t3lib is going to be a fast look up anyways as there's 
some structure we can stick to. The more expensive things will most 
likely be the extension classes - although even that won't be more than

$path = $registry['my_extension_class']; (internally)

> This is my concern. But overall - yes, it may be faster if files are 
> included only when it is truly necessary. I think that point is valid 
> and we should try it!

ok


Ingo

-- 
Ingo Renner
TYPO3 Core Developer, Release Manager TYPO3 4.2


More information about the TYPO3-project-4-3 mailing list