Hi, thanks for the module, looking at the code there's a bit of a random 'include' statement at the very top of the .module file that looks like:

/**
 * Include additional files.
 */
$dirname = dirname(__FILE__);
$includes = file_scan_directory($dirname . '/includes', '/.inc$/');
foreach (module_list() as $module) {
  $file = $dirname . '/includes/' . $module . '.inc';
  if (isset($includes[$file])) {
    require_once $file;
  }
}

This all boils down to:

require_once dirname(__FILE__) . '/includes/imageapi_optimize.inc';

The former code is massively detrimental for performance, we're hitting the disk, and searching a directory, when we know what file we're looking for. We could just replace the complicated code, with the simple code, but looking at the file, it's actually just a hook implementation, and an implementation of our own hook at that, so actually we could just implement hook_hook_info and Drupal would include the file on demand, also other modules could then do this too.

Patch to follow...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Steven Jones created an issue. See original summary.

Steven Jones’s picture

Issue summary: View changes

Added the actual code snippets to the summary, doh!

Steven Jones’s picture

Status: Active » Needs review
FileSize
3.49 KB

Here's a patch that implements a hook_hook_info, and moves the code so it'll get picked up.

ttkaminski’s picture

Noticed that same thing when inspecting the code. Installed your patch and everything still seems to work.

  • Steven Jones committed b91a90f on 8.x-2.x
    Issue #2613174 by Steven Jones: Performance issue with dynamic loading...
Steven Jones’s picture

Here's an updated patch.

  • Steven Jones committed cef098e on 7.x-1.x
    Issue #2613174 by Steven Jones, ttkaminski: Performance issue with...
Steven Jones’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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