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.
| Comment | File | Size | Author |
|---|---|---|---|
| custom_formatters-file_scanning.patch | 543 bytes | Mark Theunissen |
Comments
Comment #1
decipheredThe logic makes sense, if you show evidence if the performance increase I'd commit it no question.
Comment #2
Mark Theunissen commentedYou 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:
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.
Comment #3
decipheredI 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.