In bootstrab.inc it says:

// Call all init() and exit() hooks without including all modules.
// Only use those hooks for critical operations.
  foreach (bootstrap_hooks() as $hook) {
    module_invoke_all($hook);
  }

then in module.inc

function module_invoke($module, $hook, $a1 = NULL, $a2 = NULL, $a3 = NULL, $a4 = NULL) {
  $function = $module .'_'. $hook;
  if (function_exists($function)) {
    return $function($a1, $a2, $a3, $a4);
  }
}

The function_exists() is done on the whole list of active modules! (So all of these have to be loaded even with pages from cache!)
And in fact only 3 of my ~35-40 modules have an _init or _exit hook.

So would'n it be better to save a bool in the database for every modul having an _init or _exit?, and only loading these modules along with cached pages? You can get a hook list on module activation and save the value to the DB at this time.

hope it helps. -alex

Comments

softrusher’s picture

First read all the code.. then post ;-)

function module_list ...

if ($bootstrap) {
      $result = db_query("SELECT name, filename, throttle, bootstrap FROM {system} WHERE type = 'module' AND status = 1 AND bootstrap = 1");

so ignore this whole post!