Simplemenu is slow (and can break in multi-server environments).

On every page where simplemenu is being used, it runs code a bit like this (pseudocode):

if (simplemenu_is_enabled()) {
  variable_set('simplemenu_running', TRUE);
  // do some stuff
  variable_set('simplemenu_running', FALSE);
}

This allows other modules to behave differently - e.g. apply a different theme function to menu items - for the menus built by simplemenu. Both simplemenu_multi_menu and simplemenu_inactive_parents use this behaviour.

This can break in multi-server environments. For example, if server a sets the variable whilst server b is bootstrapping, server b will render all the menus with the new theme function, instead of just the simplemenu menus.

This also has a performance impact, because the variables-cache is being reset on every request. As an example, the strongarm module will rebuild its own cache if it discovers that the variable-cache is newer. This increases the time for a full drupal bootstrap to more than double.

The attached patch (rolled against DRUPAL-6--1) reimplements the functionality using a static variable, which address both of these problems.

CommentFileSizeAuthor
simplemenu_is_slow.DRUPAL-6--1.patch3.27 KBmanarth

Comments

AlexisWilke’s picture

Issue tags: +Performance

Hi manarth,

Great job! It's checked in. That made me discover another bug. RAII would be necessary for such programming...

Thank you.
Alexis

AlexisWilke’s picture

Status: Active » Fixed

Meant to mark as fixed, it is checked in.

mrgoltra’s picture

subscribing.

Just wondering. Has this been applied to dev release? I don't know if this applies to me. I am having an issue where I am using Domain access and simple menu stopped working on subdomains.

AlexisWilke’s picture

Yes, it's in the -dev version for now.

I have many sub-domains too, but I don't use Domain with which I had a lot of problems (not with Simplemenu though.) The problem was in link with node permissions because it's not compatible with other modules using the Grant system.

Are you using the -dev version now?

Thank you.
Alexis Wilke

mrgoltra’s picture

Thanks Alexis,

Yes I am using the dev version. It was working well with domain module. I think it might have something to do with the Boost module or page compression. troubleshooting time.

The weird part is that it works with admin account.

AlexisWilke’s picture

I use Boost. If you're using Simplemenu for end-users (anonymous) then there could be problems. I never do that on my end. I don't find Simplemenu good enough for end users. (I use Cutemenu instead!)

The compression cannot be the problem. That's for sure. But other modules could indeed interact.

One thing to test is the theme() call flag. By default, I do not call the theme() function and that has side effects for many people. The main reason for not calling the theme() is that it forces the "wrong" theme if you use a module such as themekey or Domain with the theme feature. Maybe that's what you're experiencing.

Thank you.
Alexis

mrgoltra’s picture

Thanks again Alexis. Nope Simple menu is only for authenticated users. I have tried all the settings on simple menu and disabled boost still no go. hmmmm. as far theme, it was working with the one I am using (framework) and I have tried Garland and still no go... well back to more troubleshooting.

Status: Fixed » Closed (fixed)
Issue tags: -Performance

Automatically closed -- issue fixed for 2 weeks with no activity.