Active
Project:
Facet API
Version:
7.x-1.1
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
11 Sep 2012 at 15:26 UTC
Updated:
18 Sep 2012 at 12:37 UTC
Hi, I updated from beta8 to 1.1 recently, since then I have extreme performance issues.
Using XHProf I can see FacetapiFacetProcessor::mapValues (10 calls) + facetapi_get_taxonomy_hierarchy (5 calls) together take more than 7s to finish, sometimes I even get a "The connection to the server was reset while the page was loading" in my browser. In beta8 the whole page was processed in less than 1s.
We have 2 big hierarchical taxonomies with 10-30k items each and a few other facets with up to 10 values.
Anyone else experiencing this?
sb
Comments
Comment #1
cpliakas commentedAre you processing the entire vocabulary on search pages, or do you have the hard limit set so that only a subset are acted upon?
Thanks,
Chris
Comment #2
stephanbauer commentedHi, we had it set to unlimited, seems this was the problem.
I've reduced it to 100 and it works much better, thanks!
But now the problem is, that even with only 30 root items and nothing selected so all root items should be shown, not all of them are displayed in the block.
Comment #3
cpliakas commentedstephanbauer,
Thanks for reporting back! So this is a tricky problem. How Facet API works is that the server (i.e. Solr, Database search, etc) does a lot of the processing, but then Facet API applies runtime-level stuff such as hierarchy processing, mapping, etc. Therefore it isn't really designed to do mass processing of the content, and I am not surprised that it chokes with 30k pieces of content that it has to chew through in PHP.
Regarding the parent items, though, they should inherit the counts of the child items, so the most popular items should be displayed. Are you by any chance using Search API as the search backend?
Thanks,
Chris
Comment #4
cpliakas commentedAlso...
One more thing to note is that in order to get the labels in a way that work with Drupal's various translation systems (i.e. the i18n module), it has to do a taxonomy_term_load_multiple() on all returned taxonomy terms. So for 30k docs, that is a lot of loads.
If you do need to display a large number of terms, you might be able to do this by replacing the hierarchy processing / map processing callbacks to something less generic that might not go through the various override mechanisms, but will solve your specific use case and be more performant. For example, instead of doing a taxonomy_term_load_multiple(), query the appropriate taxonomy table directly. This will break translations, but it will be more efficient.
Thanks,
Chris
Comment #5
stephanbauer commentedThanks, unfortunately translation is an issue. But I will try that, so I should use hook_facetapi_facet_info_alter() and change 'map callback' and 'hierarchy callback'?
sb
Comment #6
stephanbauer commentedHi again,
changing 'values callback' in hook_facetapi_facet_info_alter() doesn't seem to work, is there another way of altering the values?
Thanks,
sb
Comment #7
cpliakas commentedstephanbauer,
Actually, "values callback" is not currently used by anything. It is a legacy key that has an unfortunate name. Implementing hook_facetapi_facet_info_alter() is the way to go changing the "map callback" for the taxonomy terms. Make sure to clear cache after implementing the hook, otherwise it won;t get picked up.
Chris
Comment #8
stephanbauer commentedHi again, just a quick question: As I don't think there is a lot to improve in facetapi_get_taxonomy_hierarchy() and this one takes too long already I changed these two callbacks (facetapi_get_taxonomy_hierarchy() + facetapi_map_taxonomy_terms()) to only process the values that are visible in the facet block.
But unfortunately the other terms appear with their tid in the root.
Is there any way to remove the other terms from the output in an early stage so they don't have to be processed that much?
Thanks!
sb
Comment #9
giorgio79 commentedCore taxonomy functions in Drupal don't scale. But, there are contrib solutions. Have you tried this? http://drupal.org/project/taxonomy_edge
Comment #10
giorgio79 commentedCore taxonomy functions in Drupal don't scale. But, there are contrib solutions. Have you tried this? http://drupal.org/project/taxonomy_edge or http://drupal.org/project/lineage
Comment #11
stephanbauer commentedHi,
this is a bit hacked together but it works fine for me. It's very specific, checking the database and not using i18n functions for term values etc.