Possible performance bug, calling menu_translate many times call user_load

birwel - August 23, 2009 - 11:59
Project:Chaos tool suite
Version:6.x-1.0
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:by design
Description

Hello, I have a module wich implements hook_user.
I noticed that my hook was invoked many times with the 'load' option... so I made a trace to see where did these calls come from, and this is the result:

<?php
menu_get_item
[menu.inc] (ln 343)
  
menu_translate (ln 316)
    
_menu_load_objects (ln 566)
        *
callback* user_uid_optional_load
     
<b>user_load</b>
       
user_module_invoke('load')
             
myhook_user
  user_view
    user_build_content
      user_module_invoke
('view')
       
myhook_user
print theme('page', $return); [index.php] (ln 36)
 
theme('blocks', 'left')
   
theme('block', 'left')
     
module_invoke('user_block', 'view')
       
menu_tree('navigation')
         
menu_tree_check_access  // Check access for the current user to each item in the tree.
            
_menu_link_translate
              _menu_load_objects
               
*callback* user_uid_optional_load
                 
<b>user_load</b>
                    
user_module_invoke('load')
                       
myhook_user
  template_preprocess_page
    theme
('help')
     
ctools_menu_help
        ctools_menu_get_active_help
           ctools_menu_tab_root_path
             ctools_menu_local_tasks
              _menu_translate
                _menu_load_objects
                  
<b>user_load</b>
                     
user_module_invoke('load')
                        
myhook_user
              _menu_translate
                _menu_load_objects
                  
<b>user_load</b>
                     
user_module_invoke('load')
                        
myhook_user
              _menu_translate
                _menu_load_objects
                  
<b>user_load</b>
                     
user_module_invoke('load')
                        
myhook_user
             
[...] about 20 more times
?>

Seems that ctools is calling menu_translate multiple times, one for each menu item, and each call one calling user_load ...
Is that call really necessary ?

#1

merlinofchaos - August 23, 2009 - 15:36
Priority:critical» normal
Status:needs review» active

1) Not critical. C'mon.
2) "Needs review" means there is a patch attached.
3) It should be doing almost exactly the same thing that core is doing, it's basically just a copy of core code with a couple of extra features to make some things possible. So I think you'd be getting this even with ctools not in the picture.

#2

birwel - August 23, 2009 - 15:55

Do you mean that it is not a performance problem anyway ? o_O
So, do you think the problem is "originated" by ctools? or by drupal core?

#3

merlinofchaos - August 23, 2009 - 16:15

I mean if you were to go in and remove the bit in CTools that adds its own menu item to theme help and otherwise left everything the same, you would see the same problems. I'm not saying it isn't a performance issue, but that core's menu system, particularly where tabs are involved, is known to be a little overzealous.

#4

merlinofchaos - January 29, 2010 - 22:56
Status:active» by design

Marking by design unless core makes a change that I need to change along with.

 
 

Drupal is a registered trademark of Dries Buytaert.