When using mongodb field storage and memcache, the queries from these two functions are sufficiently frequent (i.e. at least once on every page request with a form on it) that they show up in the top ten queries in slow query logs for total time spent.

Both quite simple to cache. Left this needs work since I'm not sure exactly where they need to be cleared though, although they'll be caught by the wildcard cache clear elsewhere at least.

Comments

sun’s picture

#717874: Provide exportables for Mollom forms also touches those code lines. Not sure which one I'm going to tackle in-depth first.

Clearing would only have to happen after submission of Mollom's own administrative forms, I think. Unless those are submitted, the protected forms and their configuration should be the same as before.

--

However, I again have this issue here (as in some other core patch)... we are replacing a query with a query here, no? - oh, kkk... you want to prefetch or cache it away in memcached or whatnot, I understand ♥

catch’s picture

Yeah this is another one that's a no-op with db-caching but helps when you use a non-sql caching backend, and even more when you use non-sql field storage ;)

dries’s picture

Does that warrant a code comment? :)

litwol’s picture

Status: Needs work » Needs review

queuing to run tests.

Status: Needs review » Needs work

The last submitted patch, mollom.patch, failed testing.

sun’s picture

Status: Needs work » Needs review
StatusFileSize
new10.79 KB

We need to cache a little more for mollom_form_alter(), because there's a second form alter happening for delete confirmation forms. So while this patch catched the list of protected forms and mollom_form_load(), it still resulted in a second cache lookup for the delete confirmation form mapping.

Attached patch re-implements caching to account for all of that. It should result in 1 cache lookup for a unprotected form, and an additional lookup for every protected form.

sun’s picture

StatusFileSize
new10.7 KB

White-space hiccup.

Status: Needs review » Needs work

The last submitted patch, mollom-HEAD.cache_.7.patch, failed testing.

sun’s picture

Status: Needs work » Needs review
StatusFileSize
new11.99 KB

hah, nice. Learned something new about my code. :)

sun’s picture

Status: Needs review » Reviewed & tested by the community

Works! :)

sun’s picture

Status: Reviewed & tested by the community » Needs work
+++ mollom.module	13 Sep 2010 22:46:05 -0000
@@ -551,7 +551,7 @@ function mollom_data_report_multiple($en
+  $forms = &drupal_static(__FUNCTION__);

@@ -563,8 +563,13 @@ function mollom_form_alter(&$form, &$for
+  if (!isset($cache)) {

err, oopsie. :-|

+++ mollom.module	13 Sep 2010 22:46:05 -0000
@@ -563,8 +563,13 @@ function mollom_form_alter(&$form, &$for
+  if (variable_get('mollom_testing_mode', 0) && empty($_POST) && (isset($forms['protected'][$form_id]) || strpos($_GET['q'], 'admin/config/content/mollom') === 0)) {

This will still output multiple warnings, in case we alter multiple protected forms on a single page.

Powered by Dreditor.

sun’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new12.13 KB

Fixed #11.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

sun’s picture

Status: Fixed » Needs review
StatusFileSize
new3.22 KB

So this would be the cleaner variant.

sun’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
StatusFileSize
new13.1 KB

Cumulative backport to D6.

sun’s picture

Status: Needs review » Fixed

Thanks for reporting, reviewing, and testing! Committed to all branches.

A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.

sun’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Fixed » Needs review
StatusFileSize
new722 bytes

One more tiny tweak -- we don't need to invoke all hook_mollom_form_list() implementations in mollom_form_load(), as we already know from which module to retrieve the data.

sun’s picture

Status: Needs review » Fixed

Thanks for reporting, reviewing, and testing! Committed to all branches.

A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit 587ff17 on master, fai6, 8.x-2.x, fbajs, actions by sun:
    #849340 by sun, catch: Cache mollom_form_load() and query in...
  • Commit 6d255de on master, fai6, 8.x-2.x, fbajs, actions by sun:
    #849340 by sun: Follow-up to invoke hook_mollom_form_list() for loaded...
  • Commit e4e0f2d on master, fai6, 8.x-2.x, fbajs, actions by Dries:
    - Patch #849340 by sun, catch: cache mollom_form_load() and query in...

  • Commit 587ff17 on master, fai6, 8.x-2.x, fbajs, actions by sun:
    #849340 by sun, catch: Cache mollom_form_load() and query in...
  • Commit 6d255de on master, fai6, 8.x-2.x, fbajs, actions by sun:
    #849340 by sun: Follow-up to invoke hook_mollom_form_list() for loaded...
  • Commit e4e0f2d on master, fai6, 8.x-2.x, fbajs, actions by Dries:
    - Patch #849340 by sun, catch: cache mollom_form_load() and query in...