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.
And that takes approximately 6% of page execution time on an empty front page.
No component for shortcut module yet, so I put it in toolbar - although these links are built even if the toolbar isn't.
Comment | File | Size | Author |
---|---|---|---|
#12 | screenshot_007.png | 32.89 KB | catch |
#12 | screenshot_008.png | 16.49 KB | catch |
#7 | shortcut-performance-620634-7.patch | 2.01 KB | David_Rothstein |
Comments
Comment #1
David_Rothstein CreditAttribution: David_Rothstein commentedThe whole shortcut_page_build() function definitely needs some rewriting - I guess we were going to mostly take care of that as a followup in the main shortcut issue, but yeah, this is a problem.
I've looked at this function several times and I'm not really sure I even understand how it works... it puts renderable stuff in
$page['toolbar_drawer']
which the toolbar module then grabs, but since it's in the $page array, it's not obvious to me why it never gets displayed in the case where the toolbar module never grabs it... if it did, this performance bug would have been very visibly obvious :)In any case, the shortcut_page_build() function needs some rethinking.
Comment #2
sun.
Comment #3
mcrittenden CreditAttribution: mcrittenden commentedSubby.
Comment #4
Gábor HojtsyWell, I guess this part of the code was just copied from toolbar, which assumed shortcuts are built when there is a place to display them (in the toolbar). If the toolbar was disabled, it did not render shortcuts. So, now that they are separate (and shortcut does not display the shortcuts in itself if toolbar is disabled), we should only generate these links if there will be someone to pick up the links. When this "drawer API" was designed, I've suggested adding a hook instead, but got opposition to add such a very special case hook, something like hook_toolbar_drawer(). That would however serve as a trigger for shortcut module to build the links, and the performance hit would not be there otherwise.
BTW, if it really takes 6% to build the shortcut bar, then we probably have performance fixes to do elsewhere too.
Comment #5
bleen CreditAttribution: bleen commentedsubscribble
Comment #6
bleen CreditAttribution: bleen commentedout of curiosity ... what is "the main shortcut issue?"
Comment #7
David_Rothstein CreditAttribution: David_Rothstein commentedHere is a patch which takes the approach of having the shortcut module use hook_page_alter() to add a pre-render function to the toolbar. That way, the shortcuts are only built when they need to be rendered.
Comment #8
David_Rothstein CreditAttribution: David_Rothstein commentedBy the way, @bleen18, the main shortcut issue is this one: #511286: D7UX: Implement customizable shortcuts (the issue where the shortcut module was first added)
Comment #9
moshe weitzman CreditAttribution: moshe weitzman commentedThis fixes the problem at hand. We've made quite a dance for ourselves between the drawer and its contents. Not sure the complexity is helpful enough.
Comment #10
webchickHm. This patch effectively makes toolbar a requirement of shortcut? Should we spell this out in the .info file explicitly? Or is the idea that we're using a generic array index here that could be implemented by Super Toolbar or whatever?
Comment #11
Gábor Hojtsy@webchick: Well, the shortcut module is by design separated, so that it can be put under/with admin_menu module for example which can be a toolbar module replacement. And vice versa. So cross-dependencies should be optional at best.
Comment #12
catchanonmyous user triggers shortcut_set_load and shortcut_current_displayed - both of which issue queries, confirmed in devel log that these don't get triggered.
Attached screenshots showing cachegrind output - as you can see this cuts just under 5% off my test page.
Comment #13
webchickThank you for the benchmarks, catch!
Committed to HEAD.
Comment #14
David_Rothstein CreditAttribution: David_Rothstein commentedThanks!
Regarding the shortcut-toolbar coupling, this patch really didn't change much from the way it was before. In addition to other toolbar modules being able to use the same array structure (and automatically get the shortcuts inserted), we also have shortcut_renderable_links() which they can call to explicitly render the shortcuts wherever they want, plus the shortcut module provides its own block which works reasonably well even in the case where no toolbar module is installed at all.
Comment #15
David_Rothstein CreditAttribution: David_Rothstein commentedOops.