I was doing some code profiling with XHPROF and noticed that nodequeue makes some resource expensive calls to three particular functions:

  1. nodequeue_get_subqueues_by_node
  2. nodequeue_load_subqueues_by_reference
  3. smartqueue_taxonomy_nodequeue_subqueues

A static cache provides a cache for multiple calls to the functions within the same page request, something that can happen literally 100's of times during XHPROF testing (see attached screenshot)

Looking into it further I noticed that there was no usage of a static cache, or if it was used it was not actually set.

The attached patch provides a static cache for those functions, please review and adjust if needed.

Thanks.

Comments

fizk’s picture

Issue tags: +Performance
fizk’s picture

Status: Needs review » Needs work

Thanks for the patch! Why did you remove the use of drupal_static?

fizk’s picture

Status: Needs work » Needs review

Triggering automated tests.

fizk’s picture

Triggering automated tests.

Status: Needs review » Needs work

The last submitted patch, 4: nodequeue-static-cache-optimization-4.patch, failed testing.

The last submitted patch, 4: nodequeue-static-cache-optimization-4.patch, failed testing.

The last submitted patch, 4: nodequeue-static-cache-optimization-4.patch, failed testing.

davidwhthomas’s picture

Thanks fizk!

Actually yeah, should be fine to use the drupal_static central cache there

$cache = &drupal_static(__FUNCTION__, array());

Maybe was removed as didn't appear a need to clear the central cache for that function from other places, more of a private static cache.

Cheers,
David