Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
That function can possibly be called very often (currently ~92 times on our front page, lots of images) and every time it is, it calls ctools_export_load_object() which executes the same query over and over again.
Maybe it should be ctools_export_load_object() that adds a static cache, not sure, but it was easier to add it here.
Comment | File | Size | Author |
---|---|---|---|
#10 | 1258286-file-displays-static-cache.patch | 2.26 KB | Dave Reid |
#8 | static_cache.patch | 2.43 KB | Berdir |
#5 | file_entity_file_displays_static_cache.patch | 2.44 KB | Berdir |
static_cache_for_file_displays.patch | 2.49 KB | Berdir | |
Comments
Comment #1
BerdirComment #2
BerdirMoving over to File entity, as requested by Dave Reid. Patch will need to be updated, though.
Comment #3
BerdirComment #4
Dave ReidSeems like a good change.
Comment #5
BerdirSame code as before.
Comment #7
Dave ReidFile entity has switched to a 7.x-2.x branch and the 7.x-1.x branch is no longer used. Please make sure to update your Git clones.
Comment #8
BerdirRe-rolled the patch against 7.x-2.x
Comment #9
mfer CreditAttribution: mfer commentedThis still applies with a small offset.
Comment #10
Dave ReidThis static cache doesn't really do a whole lot of good performance-wise with fallback condition.
If I run the following calls:
The patch in #8 results in:
3 cache misses
3 calls to field_view_mode_settings()
3 calls to file_displays_load()
This patch results in:
2 cache misses
2 calls to file_displays_load()
2 calls to field_view_mode_settings()
Comment #11
Dave ReidActually this is easy to reproduce the bug in #8 by just calling file_displays('video', 'non-existant-view-mode'); multiple times over and over. Each time will result in a cache miss and call to file_displays_load(). Tested and committed #10 to Git.
http://drupalcode.org/project/file_entity.git/commit/20eb1bf (file_entity 7.x-2.x)
http://drupalcode.org/project/media.git/commit/cf71b86 (media 7.x-1.x)