16

After having troubles on loading time of a very important Site I installed XHPROF and looked over the statistics to see where I can improve my code.

I found something interesting that i don´t understand. Drupal calls "is_dir" over 4000 time on nearly every request and this takes about 800ms to execute. Why is that and is there a way to speed that up?

screenshot

By a loading time of two to four seconds is 800ms take a big part.

  • Do you have automatic registry rebuilds turned on? – mpdonadio Jul 7 '13 at 18:18
  • @MPD I have disabled the automatic registry rebuilds. – user18905 Jul 7 '13 at 18:30
  • What page are you looking at? Seems like it's caused by the file_scan_directory. Bet it's during cron or some administration page. – ram4nd Jul 7 '13 at 20:05
  • And this is how Drupal recognizes new modules, themes and libraries in different directories! – Bhavin Joshi Jul 17 '13 at 11:28
19

When you uninstall a module, you need to disable it first in Drupal module admin. You should then uninstall it via the "Uninstall" tab there.

The same goes for themes, disable in theme admin first.

If you for example, delete the module folder on the file system without disabling the module, Drupal will continue to search for the module in the file system, which can result, among other errors, in the issue you are experiencing.

See also: Avoid re-scanning module directory when multiple modules are missing

In answer to MPD's comment, you will need to do something like

SELECT name, filename FROM system WHERE status = 1;

and cross reference that with the modules on your file system. All enabled modules, and themes too, should be present.

There's also a function ( slightly adapted ) Martin_Dresden posted here:

https://drupal.org/node/1080330#comment-6520842

function MYMODULE_init() {

    $startingtime = microtime(true); 
    $o = '<p>Checking for dead modules ...</p>';
    $result = db_select('system')
      ->fields('system', array('filename'))
      ->condition('status', '1', '=')
      ->execute();
      $n = 1;
      $m = 0;
    foreach ($result as $row) {
      $path = DRUPAL_ROOT.'/'.$row->filename;
      If (!file_exists($path)) { 
          $o .= "#$n $path<br>";
          $m++;
      }
      $n++;
    }
    $timedif =  round(microtime(true) - $startingtime,3);
    $o .= "Total of $n active modules registered in database. $m dead entries found.<br>";
    $o .= 'Query Time: '.$timedif.' seconds';

    drupal_set_message($o);

}

That may help debug.

  • 1
    Is there a way to determine which row in {system} is the problem? – mpdonadio Jul 8 '13 at 2:01
  • @MPD answer updated with possible solution there. – David Thomas Jul 8 '13 at 4:14
  • If I disable a module but don't uninstall it, are there any disadvantages in this case compared to also uninstalling it? – Mario Awad Jul 10 '13 at 8:35
  • The module will have a row in system table! Un installation wipes everything related to the module in db and in file system if 'un install' routine is properly written! – Bhavin Joshi Jul 17 '13 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy