At the moment, the entire list of modules is loaded and then file_exists() is called for each module, looking for a .inc file. This is very slow when you have a large number of modules, as calling file_exists() on a non-existant file is a slow operation. See #1333940: Try to use is_file() instead of file_exists() in DrupalKernel::findSitePath().

The attached patch inverts the procedure - see which .inc files are are available, and include them only if the module is enabled. Much faster in my testing.

Comments

deciphered’s picture

The logic makes sense, if you show evidence if the performance increase I'd commit it no question.

Mark Theunissen’s picture

You can see some benchmarks here:

http://drupal.org/node/1333940#comment-5220916

I repeated them on the production system I'm having problems with, the key thing is that I changed the script so that it checks for a non-existent file every time:


$n = 1000000;
$t1 = microtime(true);

for ($i=0;$i<$n;$i++) {
  is_file('a' . $i . '.txt');
}

$t2 = microtime(true);

for ($i=0;$i<$n;$i++) {
  file_exists('a' . $i . '.txt');
}

$t3 = microtime(true);

print  'is_file: ' . ($t2-$t1);
print  "\nfile_exists: " .($t3-$t2);
print  "\nt1: " . $t1 . ', t2:' .  $t2 . ', t3:' . $t3;

is_file: 32.992841959
file_exists: 44.868903160095
t1: 1339684832.6899, t2:1339684865.6827, t3:1339684910.5516

It does all depend on the system - this is Linux with AFS.

deciphered’s picture

Issue summary: View changes
Status: Needs review » Closed (won't fix)

I am no longer supporting any Drupal 6 modules, as such I am marking this as closed.

However, I am open to taking on co-maintainers, if you wish to do so contact me via me D.o contact form.