Improve the functions registry efficiency

JoshuaRogers - July 27, 2009 - 21:08
Project:Drupal
Version:7.x-dev
Component:base system
Category:task
Priority:critical
Assigned:Unassigned
Status:duplicate
Description

There seems to be a great deal of conflict surrounding the registry. Much of it has to deal with the efficiency level of the registry. I have two ideas that I believe would help increase registry efficiency. Granted, there are people here who are much smarter than I.

The registry currently acts like a preloaded cache. (Well, actually, it is a preloaded cache. Anyway...)

I propose two things:
1) We quit preloading the registry. When we search the DB, if the item we are looking for is there, good. Otherwise find it. Since practically all contrib modules abide by Drupal naming conventions, the search should 99.99% of the time be a fast operation. e.g.: wysiwyg_load_editor can be found in a file that starts with 'wysiwyg' in a folder that contains 'wysiwyg' Most functions that start with drupal_ can be found in the includes directory. Using this little piece of information should allow us intellegently search for what we desire. (Then add it to the DB.) This basically turns the registry into a regular cache. This should help cut down on the size of it.

2) We cache not only the location of functions, classes and interfaces, but more importantly which menu items (note: I'm not saying path. Rather, I'm referring to the array in hook_menu.) cause which files to be included. For instance, visiting /podcasts/archive might load the particular include files needed by views, cck, date, etc. By checking the DB for our serialized or delimited list of files to include, we should be able to load only the files that are routinely needed by this location. If changed / unlisted, Drupal would save the list before terminating. This should provide a low memory/processor/db intensive means of quickly loading needed files.

#1

Damien Tournoud - July 27, 2009 - 21:20

I suggested (1) a while back, I don't remember exactly where. Basically, some simple naming conventions could help do 90% of the registry work.

(2) was studied, but deemed impractical because the same menu path can really trigger a lot of different operations, and thus a different set of files each time. For example, think about a cache miss in a block. This block will be rendered again on the next page that will happen to display this block, thus loading the set of files needed for that.

#2

catch - August 5, 2009 - 23:53

On #2, isn't the worst thing that happens we load more files than necessary until the cache entry is rebuilt again, that doesn't seem so bad compared to _registry_check_code() issuing a queries on every request.

#3

JoshuaRogers - August 6, 2009 - 00:01

It might be worth at least benchmarking to see how often it would actually have to recalculate. I'm inclined to think that even when it has to recalculate, the penalty would probably be almost negligable.

#7

kiamlaluno - November 16, 2009 - 15:38
Title:Improve Registry Efficiency» Improve the functions registry efficiency

#8

catch - November 16, 2009 - 15:57
Status:active» duplicate

The function registry was removed

 
 

Drupal is a registered trademark of Dries Buytaert.