Closed (fixed)
Project:
Path Breadcrumbs
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
12 Jul 2012 at 12:46 UTC
Updated:
3 Dec 2012 at 03:36 UTC
On a very big website with a lot of content types, taxonomy and contexts, this function takes ~150ms so about 25% of the website total rendering time.
I quickly patched it with a simple cache_get/set:
--- i/path_breadcrumbs.module
+++ w/path_breadcrumbs.module
@@ -17,7 +17,14 @@ define('PATH_BREADCRUMBS_RICH_SNIPPETS_MICRODATA', 2);
*/
function path_breadcrumbs_page_alter() {
// See if current page has path breadcrumbs.
- $breadcrumbs = path_breadcrumbs_load_variant(current_path());
+ $cache = cache_get('path_breadcrumbs:' . current_path(), 'cache');
+ if ($cache) {
+ $breadcrumbs = $cache->data;
+ }
+ else {
+ $breadcrumbs = path_breadcrumbs_load_variant(current_path());
+ cache_set('path_breadcrumbs:' . current_path(), $breadcrumbs, 'cache');
+ }
// Set breadcrumbs for current page if it exists.
if ($breadcrumbs) {
Comments
Comment #1
spleshkaDon't forget that you have to flush cache when breadcrumb was updated.
Comment #2
caschbre commented@bastnic... how was performance after this patch?
@Splenshka... are there plans to commit this?
Comment #3
spleshka@caschbre, patch is not complete. I have to dig dipper before commit this.
Comment #4
bastnic commented@caschbre very good of course. But as I said, I bypass a lot of things with this dummy patch. It was just to prove that this function have a big performance cost. But the website in question was already very big and fast so the 25% is not the average cost I think, but it's still too big.
Comment #5
caschbre commentedGood stuff!
I'm porting a large D6 site to D7 and want to switch from using custom_breadcrumbs to path_breadcrumbs. Performance is pretty important given the large quantity of content / users.
Comment #6
spleshkaPerformance was imporoved in 7.x-3.x (see commit 6a77580)
Comment #7
spleshkaClosing this issue. Please, feel free to reopen it if you have any questions.