Currently, _registry_rebuild calls module_rebuild_cache() just to get the list of available modules. This is slow because it executes a UPDATE-query for every enabled moduled and also parses all info files, even those of disabled modules.

I discussed this with chx (ok, the other way round, he explained me that we don't need it :)) and it seems we can replace it with just calling drupal_system_listing(), system_get_files_database() and drupal_parse_info_file() (only for enabled modules, in opposite to module_rebuild_cache())

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir’s picture

Improved inline comment.

cburschka’s picture

+1 - this would be a good performance boost!

I've applied and tried it out, and have had no problem rebuilding the code registry with this patch. Don't have benchmarks, though.

catch’s picture

Priority: Normal » Critical
Status: Needs review » Reviewed & tested by the community

admin/build/modules

Before:

Executed 668 queries in 226.55 milliseconds.

After:
Executed 607 queries in 234.22 milliseconds.

This is a query for every file in every module right? So presumably we could save several hundred queries when contrib modules are installed.

Berdir’s picture

@catch It saves atleast one UPDATE query for every module, not sure if there is more.

In your test, it is actually slower with my patch, even if there are less queries. I assume this has another reason that doesn't have anything to do with my patch.

catch’s picture

I think that's just because there's a lot of queries so potentially lots of variation.

I just hit the page a couple more times and got:

Executed 607 queries in 211.78 milliseconds.

So the patch isn't slowing anything down. If we need benchmarks for this I'll run them, but just looks like a no-brainer to me.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Good catch, and looks good. Committed to CVS HEAD.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.