Performance impact of extra files in the modules directory

Events happening in the community are now at Drupal community events on www.drupal.org.
TallDavid's picture

In a recent series of articles entitled Drupal 6.x Performance Guide, in the section entitled Move third party libraries outside the modules folder, it is stated:

Every file in the modules folder is read for inclusion in the Drupal stack. If you store large third party libraries, such as the YUI library or third party WYSIWYG editors, this will slow down Drupal. The modules folder is usually in /sites/all/modules or /sites/all/modules/contrib. To avoid such unnecessary file reading, move all your third party libraries to a special folder at /sites/all/libraries.

I know that there are administrative actions that trigger recursion of the files in the ...\site\all\modules tree, but, this will only affect a small number of administrative users. Are there other cases in which extra files in the ...\site\all\modules tree will affect general Drupal performance in a significant way?

Comments

I don't think whoever wrote

Garrett Albright's picture

I don't think whoever wrote that article knows what they're talking about. A file in the modules directory is not automatically loaded by Drupal, unless it's the .module (and in some cases, .install) file for an enabled module, or is loaded by an enabled module; or it's a module's .info file, which is loaded on the module enable/disable page. Files in the modules directory are not just loaded by virtue of their existence.

That being said, keeping third-party stuff in a separate libraries directory is still a good idea (if the module supports it), for other reasons; namely, it makes it easier to upgrade the module and the library independently of each other. That's not really a performance thing, though.

Efficiency

Daniel Norton's picture

They actually got it half right because although it's not automatically loaded, the same code in two different module directories could easily be referenced twice, which is also likely to cause a name-collision failure.

Also not a performance

Garrett Albright's picture

Also not a performance issue… and how would that ever happen in the first place? Unless someone was keeping contrib modules in at least two different directories or something…

The entire /modules folder is

dalin's picture

The entire /modules folder is only scanned when you load /admin/build/modules (so Drupal can find the .info, .module, and .install files). So keeping libraries in sites/all/libraries will help with performance of that page. It's also a good practice for easier upgrades, and you can tell your IDE to ignore that folder to speed up code completion and searches.

--


Dave Hansen-Lange
Director of Technical Strategy, Advomatic.com
Pronouns: he/him/his

True if by "scanned" you mean

Garrett Albright's picture

True if by "scanned" you mean the entire hierarchal directory structure is explored, but only files with .info extensions are loaded, so the impact on speed and memory of storing libraries there is negligible in my opinion.

That being said, I still recommend avoiding it if possible, for reasons I mentioned above.

When you use ctools, this

jcisio's picture

When you use ctools, this modules scan the modules folder, to look for .inc files in plugins folders. But I don't know how frequently it does that.

First of all, a lot of module

morningtime's picture

Hi, someone emailed me about this thread. I think a lot of modules nowadays recommend placing third party libraries in a separate folder. So its the way to go anyway. But as @dalin points out, at some point the entire /module folder is scanned. So moving third party libraries outside of it is -however little- a performance boost, at least for that admin/build/modules page.

Reason is, I remembered this tip from my early drupal days 2-3 years ago, when installing CiviCRM (tons of files in /modules) on a shared host would kill my site performance.

The guide I wrote does not claim to be complete or perfect, its just a free resource, and most tips are alright.

High performance

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: