I was deploying beans from my staging site to production but I kept getting a request time out error. It looks like when calling drupal_http_request the max timeout of 30 seconds was being reached. So I investigated the issue further.

I noticed if I commented out menu_rebuild in bean_reset that the time to create a bean would drop from 30 seconds to about 5 seconds. I was wondering what is the rationale for having menu_rebuild inside bean_reset which itself is called in bean_save. So every time I save a bean menu_rebuild is being called. This seems like an outrageously expensive operation particularly for large sites.

Looking through the previous commits it seems menu_rebuild was only added in bean_reset in order to support the following code in hook_menu:

  foreach (bean_get_types() as $type) {
    if (!empty($type)) {
       $items['block/add/' . $type->buildURL()] = array(
         'title' => $type->getLabel(),
         'title callback' => 'check_plain',
         'page callback' => 'bean_add',
         'page arguments' => array($type->type),
         'access arguments' => array('create any ' . $type->type . ' bean'),
         'file' => 'includes/bean.pages.inc',
      );
     }
   }

Is there anything we can do to fix this because it makes saving beans very slow, as well as deploying them and leveraging them in an install profile. Basically anytime bean->save is called.

Comments

sylus’s picture

Title: Performance with bean_reset and menu_rebuild » Performance with bean->save and menu_rebuild

Modifying title.

spotzero’s picture

This is likely related to this issue: https://drupal.org/node/2060831

spotzero’s picture

If the menu_rebuild is only required to build the menu paths for the bean types, as the issue #1850814 (https://drupal.org/node/1850814) would suggest, then if this menu entry was replaced with something like:

    $items['block/add/%beantype'] = array(
         'title callback' => 'bean_type_title',
         'title arguments' => array(2),
         'page callback' => 'bean_add',
         'page arguments' => array(2),
         'access callback' => 'bean_type_access',
         'access arguments' => array(2),
         'file' => 'includes/bean.pages.inc',
     );

Then you'd just need to implement the two extra callbacks mentioned; "bean_type_title" and "bean_type_access".

Does this approach seem sound?

ottawadeveloper’s picture

sylus’s picture

Status: Active » Closed (duplicate)

At this point this is a duplicate of: https://drupal.org/node/2060831 so closing.