Problem/Motivation

I've had quite some trouble with the i18n_field integration on a site with lot's of field / field instances.
Every time an entity related configuration was changed (imagine entityforms) and hence the entity_property_info cache was cleared I've got thousands of database queries to fetch field related translations.
This happened for every enabled language and often multiple times at once - pretty much throwing the database / site in a death spin.

Proposed resolution

  1. Add a locking to these expensive functions to avoid stampeding.
    The patch adds a locking to i18n_field_i18n_object_info_alter() - the other lock should be located in the entity module in entity_get_property_info(), patch there follows.


  2. Add a cache priming when we know an expensive function is about to run.
    Even the "non caching" default class i18n_string_textgroup_default uses an object instance specific cache for i18n_string_textgroup_default::multiple_translation_search() and i18n_string_textgroup_default::load_strings(). We can call these functions with no conditions, prior to expensive functions, to fetch all translations at once. Potentially reducing hundreds of db requests to about two.
    Attention: This relies on following patch to work properly: #2986171: i18n_string_textgroup_cached::multiple_cache_get() not properly filtering return value


  3. Inject translations instead rebuilding the whole cache.
    i18n_field_i18n_object_info_alter() - it looks like we can inject the translations rather than flushing the whole cache again.

These adjustments showed massive improvements on the page that suffered from the heavy database load.

Remaining tasks

Reviews needed.

User interface changes

None

API changes

None

Data model changes

None

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

das-peter created an issue. See original summary.

joseph.olstad’s picture

Code looks good. I have a comment for the related one though.

joseph.olstad’s picture

Status: Needs review » Reviewed & tested by the community

Ok, looks good, das-peter, feel free to put this in the dev branch, let it simmer in there for a bit.

  • das-peter committed e4f44fa on 7.x-1.x
    Issue #2986187 by das-peter, joseph.olstad: Performance enhancements:...
das-peter’s picture

Status: Reviewed & tested by the community » Fixed

Here we go :) Committed & pushed.
@joseph.olstad Thank you very much for your feedback - highly appreciated.

Status: Fixed » Closed (fixed)

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