Is there potential performance loss by using multiple nodeapi calls instead of one? I have a fairly large site with multiple custom modules. I've started to split some of the larger modules out into smaller more maintainable ones.

I have one particular module that I'm splitting into three. It has a hook_nodeapi function that does various different things, would there be much of a performance loss in splitting one nodeapi call into 2 or 3? Has anyone done any benchmarks on this subject?
There is a performance loss with additional modules. Mostly due to more opening parsing and function_exists() and memory use.

Node api in 6 will be called for every node action and called for each node. (in 7 multiple nodes can be used at once and there is a separate hook for each action)

So if you are careful:


Put all your code inside a switch($op);
Check the content types to work on what you need
Keep DB queries to a minimum 


there will be little overhead (some but not overwhelming).

If on the other hand your nodapi call, share DB queries (or can share DB queries), have a lot of setup / code which is common, then you may start to be hurting yourself performance wize.

One way round this is to be a bit more selective with the code you include:

mymodule_nodeapi($op, ...) {
 switch($op) {
  case 'load':
    // Insert common code here.
    if ($node-&gt;type == 'my_complex_node_type') {
      module_load_include('inc', 'mymodule', 'complex_type');
      mymodule_complex_load($node);
    elseif ($node-&gt;type == 'some_other_node_type') {
      module_load_include('inc', 'mymodule', 'other_type');
      mymodule_other_load($node);
    }  
  break; 
 }
}


Rough pseudo code

You can keep your code in seperate files to aid maintainability and keep load time down as files are only included/parsed when needed.

The downside is you need to manage the include and callback yourself rather than relying on module_invoke_all.