Problem/Motivation
I got a ticket to investigate our drush cc all because now it is so slow to require a maintenance window. So I did a profile run and realized there's just too much functionality hanging off _menu_navigation_links_rebuild despite it does nothing in 99.99% of cases.
Proposed resolution
Similarly to #512962: Optimize menu_router_build() / _menu_router_save() but disjoint from it, do not rebuild the menu links which belong to unchanged router paths.
This simple approach needs to be refined as menu link properties can be defined in hook_menu
. In this case, reuse the existing item query _menu_navigation_links_rebuild
to check these properties didn't change. In one more optimization step, exempt known core paths from this query.