Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently the logic for breakpoints triggers a menu rebuild for every enabled theme and then for each of those themes for every enabled breakpoint. This will then call menu_rebuild on line 102 under the breakpoints_themes_enabled() function which itself gets triggered from breakpoints_flush_caches.
Remove the menu_rebuild just to test caused my drush cc all to perform significantly faster by about 1min and 5 seconds.
We first caught this performance issue when using XHProf and then Xdebug + Cachegrind and noticed breakpoint_flush_caches was at the top of the stack.
Comment | File | Size | Author |
---|---|---|---|
#13 | 2415363-breakpoints-menu_rebuild-13.patch | 2.21 KB | hefox |
#8 | breakpoints-2415363.patch | 1.95 KB | quicksketch |
#1 | performance_issue_with-2378449-1.patch | 1.32 KB | sylus |
Comments
Comment #1
sylus CreditAttribution: sylus commentedI have added a quick patch to the hook_flush_all_caches implementation to disable the menu_rebuild till can find a better way of calling the function.
Results were as follows:
a) Before Patch
$ time drush cc all
real 2m45.362s
user 1m47.015s
sys 0m13.277s
b) After Patch
$ time drush cc all
real 0m55.370s
user 0m38.866s
sys 0m4.568s
Comment #2
joseph.olstadSylus, nice work finding this problem and getting a solution out! Really appreciate this one! :)
Comment #3
p-andrei CreditAttribution: p-andrei commentedHey module maintainers! Any plans to include this patch in next releases? Its extremely annoying to wait for so long on each clear cache.
Comment #4
Dave ReidUse variable_set('menu_rebuild_needed', TRUE) instead of calling menu_rebuild()
Comment #5
Dave ReidI think this would be resolved with #2415363: Replace calls with menu_rebuild with variable_set('menu_rebuild_needed')?
Comment #6
quicksketchConfirming this issue. We're seeing Breakpoints module responsible for up to 30 seconds of additional processing time due to rebuilding the menu once per enabled theme. I think Dave Reid's approach is less disruptive and solves the issue in the right way. The patch in this issue would still rebuild the menu twice, whereas #2415363: Replace calls with menu_rebuild with variable_set('menu_rebuild_needed') keeps the menu only built a single time during cache clears.
Comment #7
quicksketchThis patch should be applied in addition to Dave Reid's patch. See my explanation in #2415363-4: Replace calls with menu_rebuild with variable_set('menu_rebuild_needed'). I do think the parameter to
breakpoints_themes_enabled()
could use a better name than$force
however, how about$rebuild_menu
?Comment #8
quicksketchBecause this issue overlaps with Dave Reid's patch from the other issue, I've combined them together if we'd prefer to just apply one patch. And this renames the parameter to
$rebuild_menu
.Comment #9
joseph.olstadHi quicksketch, I was only able to apply your patch by it'self, neither Sylus's patch, nor Dave Reid's patch apply once yours is applied. Have these patches been rolled into one with your patch?
So to avoid redundant calls to menu_rebuild we just need breakpoints 7.x-1.x and your patch from comment #8 ? or is there another patch necessary?
Here's how I applied your patch:
this works, but if I try applying Dave Reid's patch on top or Sylus's patch on top there's reject messages.
Please clarify then I'll proceed with testing your patch.
Comment #10
quicksketch> Hi quicksketch, I was only able to apply your patch by it'self, neither Sylus's patch, nor Dave Reid's patch apply once yours is applied. Have these patches been rolled into one with your patch?
Sorry I wasn't clear! Yes, the patch in #8 is a combined patch that includes both Dave Reid's patch and Sylus's patch.
Comment #11
sylus CreditAttribution: sylus commentedThanks @quicksketch all of your improvements are more then reasonable and agreed about renaming force to menu_rebuild.
This patch worked for me and still fixed the performance issue :)
Comment #13
hefox CreditAttribution: hefox commentedquick 3 line change to only set the variable in breakpoints_themes_enabled if TRUE and something has actually changed.
Unfortunately back to needs review
Comment #14
RavindraSingh CreditAttribution: RavindraSingh as a volunteer and at Srijan | A Material+ Company commentedmaking #13 RTBC, as i have tested this.
Comment #15
Stefan Lehmann CreditAttribution: Stefan Lehmann commentedAlso was able to apply patch and it reduced the cache clear time significantly. We have a lot of websites running with the picture module which has a dependency to this module and it would be really good to see this patch go into the major version release.
Comment #17
attiks CreditAttribution: attiks at Attiks commentedThanks, I somehow missed this one, committed and new release created