Problem/Motivation

ctools_token_content_type_content_types() is basically a wrapper around token_info() which has already static caching. But to extend the data returned by token_info(), ctools_token_content_type_content_types() does some other stuff e.g. new ctools_context_required().
And as there can be quite a bit data to wrap it can take some CPU time to handle that.

Proposed resolution

Add a static caching as token_info() does.
I couldn't find a location where the static cache of token_info() is flushed so I think there's no need to add such a thing for the static cache of ctools_token_content_type_content_types().

Remaining tasks

Reviews needed

User interface changes

None.

API changes

None.

Comments

ezra-g’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new64.9 KB

I tested in customized Drupal commons 7.x-3.x site that made extensive use of Panels and in some pages this patch eliminated ~128,000 calls to the t() function, significant emory use, and reduced page execution time by 2 seconds. We haven't noticed any ill effects. Marking as RTBC.

maximpodorov’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new8.06 KB

I would suggest to add more caching, not just in token_content_type. Number of t() calls reduces significantly, really.
The patch implements more static caching, utilizes drupal_static_fast pattern and moves repeated things out of loops.

japerry’s picture

StatusFileSize
new9.09 KB

Here is a patch that applies cleanly to the latest patches in ctools

japerry’s picture

For bookkeeping:

https://drupal.org/files/ctools-add-static-cache-to-ctools_token_content...

Was applied in this commit:
http://drupalcode.org/project/ctools.git/commit/cdc45d0d35c096d227251dd9...

The patch in #2/#3 should add the functionality listed in #2.

maximpodorov’s picture

Is patch #3 supposed to be committed? :)

andypost’s picture

Status: Needs review » Reviewed & tested by the community

#3 is just a re-roll of #2 so RTBC

japerry’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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