Slow D7 functions during a cc all

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
mikeytown2's picture

Decided to see what's causing a slow cache clear on our D7 site. Below are the functions that should be looked at to see if they can be optimized.

field_views_data 172ms
_theme_build_registry 1242ms
imageapi_optimize_init 36ms (contains eval!)
token_info 506ms
admin_menu_merge_tree 1064ms
theme_admin_menu_links 1746ms
views_block_info 1103ms
menu_rebuild 4879ms
views_menu_alter 2708ms
_menu_router_build 115ms
_menu_router_save 1232ms
_menu_navigation_links_rebuild 44ms
features_flush_caches 917ms
entity_flush_caches 315ms
block_flush_caches 179ms
advagg_get_info_on_files 113ms
system_date_formats_rebuild 55ms
field_flush_caches 36ms
registry_rebuild 749ms
system_rebuild_theme_data 73ms

Some of these functions could be improved with better queries, smarter file scans, and better php logic. Thought I would share what I've found so far. Most of calls inside menu.inc can be fixed without a core patch; this will be done in this issue for APDQC: https://www.drupal.org/node/2495985. Other parts can be done in a background process via HTTPRL.

Comments

I have a definite solution

pounard's picture

I have a definite solution for this: don't use views, it's not really a joke, views does very bad things on cache clear calls.

And more seriously, would menu scale to hundreds of different custom menus with hundreds of entries each ? I may encounter that use case in a few months, and menu_rebuild doesn't look to be very well performing regarding your numbers.

Pierre.

Views menu rebuild woes -

moshe weitzman's picture

Views menu rebuild https://www.drupal.org/node/941970. Affects D7 as well.

I've been doing some

alexmoreno's picture

I've been doing some profiling and found some peaks around field_views_data

Digging a bit, ended in drupal_array_merge_deep_array()

where there is a recursion. I think it could be improve a bit using a recursive (if possible), but not (yet) tested