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.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | ctools-add_static_cache-2049087-3.patch | 9.09 KB | japerry |
| #1 | QbrcDW3YZ492RBhbCmLs8pD89ex8pUb6BX4j8v7Peoc.png | 64.9 KB | ezra-g |
| ctools-add-static-cache-to-ctools_token_content_type_content_types.patch | 1.7 KB | das-peter |
Comments
Comment #1
ezra-g commentedI 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.
Comment #2
maximpodorov commentedI 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.
Comment #3
japerryHere is a patch that applies cleanly to the latest patches in ctools
Comment #4
japerryFor 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.
Comment #5
maximpodorov commentedIs patch #3 supposed to be committed? :)
Comment #6
andypost#3 is just a re-roll of #2 so RTBC
Comment #7
japerryGreat, its committed now:
http://drupalcode.org/project/ctools.git/commit/a333dfc