3

A related question explains this issue. drupal_find_theme_functions called on every page - is our theme registry being rebuilt?

With omega, there are 3 themes total (Alpha, Omega, and Subtheme) so this adds to the number of times drupal_find_theme_functions is called.

Shouldn't base hooks be stored in the cache? I see that it has logic to check to see if they are already set, but it seems like every time the page loads drupal_find_theme_functions calls preg_grep about 2,014 times. It takes 4,969,243 microseconds. I have a lot of modules installed, and this doesn't seem very efficient for every page load. Can someone please advise?

Edit

Looks like the issue is APC related, or at least I think so.

I installed APC and memcached previously to increase performance. I'm noticing some cached items are going missing even when they're set to not expire. I have features installed and tested features_get_info()'s cache which should never expire. It remains set for 5-10 minutes then goes away. Looking at apc.php shows 192M of 192M free about 500K usage, so something's definitely wrong. I'm not sure if the default APC/Memcache settings attempt to store the theme registry or not, but I'm going to play around with ttl values and see what works. If anyone can help, I'll mark this as answered.

  • 2
    I have the same setup (Alpha, Omega, and Subtheme) on several sites and none of them exhibit this behaviour...drupal_find_theme_functions() is only ever called when the registry is rebuilt. I added debug code directly into drupal_find_theme_functions() to confirm, and it only fires on the rebuild. One of the sites in particular has a lot of contrib modules installed, and still doesn't have the problem. I'd suspect a combination of contrib/custom modules installed that are causing it, try disabling those methodically and see if you can isolate it – Clive May 5 '13 at 16:22
  • Thanks for the assurance that it's something I'm doing wrong. I added a backtrace to drupal_find_theme_functions and cleared my cache. After the initial debug statements appeared, subsequent refreshes aren't showing any output. Looks like an intermittent issue at best. – Arosboro May 5 '13 at 17:20
  • No worries, the list of functions here might help as well, those all call drupal_theme_rebuild() which clears the registry. Might help in hunting it down – Clive May 5 '13 at 17:23
  • It looks like it's being called when views_plugin_display_block() calls theme() which in turn calls get_theme_registry(FALSE), building a runtime ThemeRegistry instance in _theme_load_registry. I'm not sure if that normally rebuilds the registry or just uses the cache, but I'm not seeing drupal_theme_rebuild() in any xhprof logs. – Arosboro May 5 '13 at 18:07
  • It might come indirectly, say from a call to drupal_flush_all_caches() – Clive May 5 '13 at 19:43

Browse other questions tagged or ask your own question.