The attached patch file (which should be placed in the parent directory above Advanced help module directory to be applied properly) should increase performance of each page request.
It stores the result of help file discovery (which runs via hook_init() for everey page request) in Drupal's core cache table.
So you have to click your "Empty cache" button (on performance settings admin page or in Devel navigation block) after adding new help files to start a new discovery cycle.
Maybe this patch is helpful for people that are interested in performance tweaking for huge Drupal installations.
Another idea could be integrating this patch in the next release and give the user a way to decide if cache should be used (e.g. by setting a variable in settings.php or via an admin page).
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | advanced-help-cache-1197396-19.patch | 4.61 KB | das-peter |
| #9 | advanced-help-cache-3.patch | 4.75 KB | c960657 |
| #9 | advanced-help-cache-3-D6.patch | 4.66 KB | c960657 |
Comments
Comment #1
c960657 commentedI agree - this function could benefit from using a cache.
I suggest you move the cache_get() logic inside the if (!isset($cache)) { block.
I suggest that you rename the existing $cache variable used for holding the result array to e.g. $ini or $return, and then use $cache exclusively for holding the cache object returned by cache_get(). This naming convention seems more in line with Drupal core. Reusing variable names makes the code hard to read.
Please also remove the "// NEW ..." comments from the patch. These are not necessary. Using a cache in this way is fairly obvious, so I don't think there is a need for elaborate comments.
Comment #2
c960657 commentedOh, and please create the patch for the 7.x version of the module. Once it has been applied to 7.x, we can backport it to the 6.x version.
Comment #3
m_z commented@c960657: thanks for your answer
Are you a maintainer of this module?
My suggested patch was intended to give an idea how the advanced_help module's performance could be improved. So I tried to make only small modifications to make it clear what is needed to increase performance. Since I don't use the 7.x advanced_help module and due to time limitations, I won't modify my initial patch.
@c960657 or anybody else: Feel free to change the patch above (see #1). I would welcome seeing it in a next release.
Comment #4
c960657 commentedNo, I am not the maintainer - just a user who noticed the performance issue.
Here is a patch for 7.x.
Comment #5
c960657 commentedAnd a D6 backport.
Comment #6
m_z commented@c960657: I reviewed your code and it looks ok --> maybe another user could test your patch (especially for the 7.x version) to make this issue "rtbc"
Your modifications in advanced_help_get_topics() and advanced_help_get_settings() are unnecessary in my opinion, but maybe it is more straightforward to switch to "your" $ini variable name also in this 2 functions.
Many thanks for your effort.
I would like to see the patches in future relases.
Comment #7
c960657 commentedI renamed $cache to $ini in advanced_help_get_topics() and advanced_help_get_settings() for the sake of consistency. I think it makes the code more difficult to read if $cache in one place contains a cache object and in another closely related function it contains an array.
Comment #8
m_z commentedI found that there must be language specific cache IDs for proper working in multi-language Drupal sites.
So all you have to do is adding
$GLOBALS['language']->languageat the end of the $cid parameter of each cache_get() or cache_set() call.
For my initial patch the new lines must look so:
Comment #9
c960657 commentedGood catch. Here are updated patches.
Comment #10
m_z commentedHas anybody tested these patches?
Comment #11
c960657 commentedI have been running the D6 patch on a large production site for some time now. But we don't use advanced help a lot.
Comment #12
m_z commentedI also run the D6 patch successfully since some months, so issue status should be changed to "rtbc", right?
Comment #13
c960657 commentedIt would be nice to get some feedback (review or testing) on the D7 patch also.
Comment #14
m_z commentedIt seems that our performance improvement isn't a big topic of interest in the community... ;-)
I reviewed the Drupal 7 patch and see no problems. It looks fine.
So ready for "rtbc"? I would say "yes".
Comment #15
c960657 commentedYes, I agree.
Comment #16
joshmillerThis patch is now a part of the Commerce Kickstart 2 distribution... thanks for the performance bump :)
#1708072: Apply a patch to advanced help for performance
Comment #17
das-peter commented+1 for that! I've just profiled configuring a views field and advanced help "wastes" nearly one third of the processing time.
Comment #18
redndahead commentedThis patch no longer applies in d7. Could we get a re-roll?
Comment #19
das-peter commentedRe-rolled D7 patch.
Comment #20
redndahead commentedCan someone test this re-roll and mark it as RTBC? After this one is RTBC then I'll commit it and do a 1.1 release.
Comment #21
sherakama commentedTested patch in #19 against latest dev and issue seems to be resolved.
Please proceed with stable release.
Comment #22
redndahead commentedThis has been committed. thanks