Short story: When installing more than one feature at a time, for example using drush, an install profile using dependencies or features_install_modules(), every time features are requested to be rebuilt, every feature in the system is reverted regardless of its status.

Long story: While building a complex, installation profile based site referencing lots of feature as dependencies, by looking at Drupal's log files we were noticing that features are rebuilt over and over again during deployment using drush site-install. This happens because features_get_component_states() maintains a static cache of component states, causing a full rebuild of all active (or to be activated) features each time hook_flush_caches() is triggered. By resetting the component states we were able to avoid those multiple rebuilds; as a byproduct the install time could be significantly reduced. As the to-do indicates, resetting the cache should probably happen way more often than now, which explicitly checks for being triggered by drush.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

smk-ka’s picture

Status: Active » Needs work
FileSize
1003 bytes

Needs work regarding the to-do. Possibly resetting the static cache at the end of a feature rebuild (and only in case there really was something to rebuild) would be more ideal.

smk-ka’s picture

#1195432: Use dependency information when importing is a prerequisite for this patch.

febbraro’s picture

Adding a tag for webchick

febbraro’s picture

@smk-ka Trying to understand how to approach the @todo.

To get up to speed, by resetting the component state cache you are limiting the rebuilding when multiple features are enabled in the same pass? Have not fully grokked that part yet. Will continue pouring through the code for that piece. Any hint you can give me will help.

Back to the cache clearing, seems that if we can find the right point in time to clear the static, we can move that static $cache in features_get_component_states to a drupal_static so we can clear it from wherever that place might be?

tirdadc’s picture

Tested this with both the manual installation process and using drush site-install. While it makes no difference in the former case, it does result in a huge performance boost when using drush to instantiate a site, even with 5-7 features.

What I can't figure out yet is how given that features_get_component_states() gets called 3 times with or without the patch when using drush site-install, and forcing the reset actually unsets other static cache variables in a number of other places too (including features_get_normal and features_get_default). Can you please provide any details on where the fact that the component states are cached causes a full rebuild each time?

febbraro’s picture

Status: Needs work » Needs review
FileSize
969 bytes

Rerolled with a diff mechanism to test for drush.

tirdadc’s picture

This one yields the same performance gain as the original patch during a drush site-install.

febbraro’s picture

Status: Needs review » Patch (to be ported)

Committed to 7.x branch. http://drupalcode.org/project/features.git/commit/cd5ccbf

hefox anything to be ported here?

febbraro’s picture

Removing release blocker tag for D7

febbraro’s picture

Version: 7.x-1.x-dev » 6.x-1.1

  • febbraro committed cd5ccbf on 8.x-3.x
    Issue #1188066 by smk-ka, febbraro: Fixed Excessive rebuilding if...