"drush fra" takes a lot longer that doing "drush fla" and then grep'ing out those in "overridden" or "needs review" status and then running "drush -y fr module" on only those modues that need to be reverted. We do have quite a few features but on our site running "drush fla" and "drush -y fr xxx" on one feature takes around 2 min 30 seconds user time from "time" command. However running "drush -y fra" on site in same state takes well over 5 minutes.
This is true on both our D6 and our D7 sites. We are currently on 7.x-1.0-beta4 and 6.x-1.2 versions of features.

In next comment will include a patch that speeds up greating and leaves "drush fra" to still work as before in results.

Here are time results on our site:

root@a.bcmiller.allplayers.com:/mnt/apci/main/www/sites/all/modules/contrib/features# time drush -y frn
The following modules will be reverted: apci_profile_feature
Do you really want to continue? (y/n): y
Reverted variable. [ok]
Do you really want to revert variable? (y/n): y

real 2m30.873s
user 2m21.670s
sys 0m4.290s
root@a.bcmiller.allplayers.com:/mnt/apci/main/www/sites/all/modules/contrib/features# time drush -y fra
The following modules will be reverted: apci_admin_lite_feature, apci_auto_schedule_events, apci_brackets, apci_broadcast_messaging, apci_brochure, apci_calendar, apci_commerce, apci_defaults, apci_event_conflict, apci_feature_background_check, apci_file_uploads, apci_friends_feature, apci_groups, apci_group_operations, apci_members, apci_messaging_feature, apci_misc_feature, apci_mobile_calendar, apci_mobile_defaults, apci_mobile_event_page, apci_mobile_groups, apci_mobile_profile, apci_password_policy, apci_profile_feature, apci_public_api_services, apci_relationships_panel, apci_sms, apci_sports_events, apci_subgroups, apci_webform, spaces_calendar, spaces_dashboard, spaces_og_registration, spaces_photos, spaces_store
Do you really want to continue? (y/n): y
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
^P^PCurrent state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Reverted variable. [ok]
Do you really want to revert variable? (y/n): y
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]
Current state already matches defaults, aborting. [ok]

real 5m30.606s
user 4m53.990s
sys 0m29.920s

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bcmiller0’s picture

Here is a patch file, we have used to allow "drush fra" to have the same outcome . The only difference it it runs much faster when few features need to be reverted, and also gives a "drush fla" display at the beginning to show current status of all features.

Here is a time output for when only one feature needs to reverted for comparison to results above.
time drush -y fra
Name Feature Status State
APCI Admin Lite Feature apci_admin_lite_feature Enabled
Auto Schedule Events apci_auto_schedule_events Enabled
Tournament Brackets apci_brackets Enabled
APCI Broadcast Messaging apci_broadcast_messaging Enabled
APCI Brochure apci_brochure Enabled
apci_calendar apci_calendar Enabled
APCI Commerce apci_commerce Enabled
APCI Defaults apci_defaults Enabled
APCI Event Conflict apci_event_conflict Enabled
Background Checks apci_feature_background_check Enabled
Downloads apci_file_uploads Enabled
APCI Friends Feature apci_friends_feature Enabled
Group Info apci_groups Enabled
APCI: Group Operations apci_group_operations Enabled
Members apci_members Enabled
APCI Messaging Feature apci_messaging_feature Enabled
APCI Misc Feature apci_misc_feature Enabled
apci_mobile_calendar apci_mobile_calendar Enabled
APCI Mobile Defaults apci_mobile_defaults Enabled
apci_mobile_event_page apci_mobile_event_page Enabled
apci_mobile_groups apci_mobile_groups Enabled
apci_mobile_profile apci_mobile_profile Enabled
APCI Notifier Feature apci_notifier_feature Disabled
APCI password policy apci_password_policy Enabled
APCI Profile apci_profile_feature Enabled Overridden
APCI: Public API Services apci_public_api_services Enabled
APCI Relationships Panel apci_relationships_panel Enabled
APCI SMS apci_sms Enabled
Sports apci_sports_events Enabled
Subgroups apci_subgroups Enabled
Webforms apci_webform Enabled
Features Tests features_test Disabled
Feeds Fast News feeds_fast_news Disabled
Feeds Import feeds_import Disabled
Feeds News feeds_news Disabled
Calendar spaces_calendar Enabled
Spaces Dashboard spaces_dashboard Enabled
Registration spaces_og_registration Enabled
Photos spaces_photos Enabled
Store spaces_store Enabled
Spaces Tests spaces_test Disabled

The following modules will be reverted: apci_profile_feature
Do you really want to continue? (y/n): y
Reverted variable. [ok]
Do you really want to revert variable? (y/n): y

real 2m37.800s
user 2m25.250s
sys 0m4.390s

bcmiller0’s picture

Here is patch for version 7.x-1.0-beta6

longwave’s picture

Status: Active » Needs review
bcmiller0’s picture

re-rolled patches replacing tabs with spaces...

bcmiller0’s picture

sorry missed on tab on d6 version

smk-ka’s picture

Title: drush features-revert-all or "drush fra" is slower than needs to be. » drush features-revert-all performance improvement
Version: 7.x-1.0-beta4 » 7.x-1.x-dev
FileSize
2.37 KB

Nice, this patch really helps cutting down the time for feature reverts for large projects. However, I didn't like the tampering with drush_features_list(), so here is my version which tries hard to avoid any unnecessary duplicate code execution by adapting only the required parts from drush_features_list().

hefox’s picture

+++ b/features.drush.inc
@@ -602,26 +602,47 @@ function drush_features_revert() {
+        switch (features_get_storage($module->name)) {
+          case FEATURES_OVERRIDDEN:
+          case FEATURES_NEEDS_REVIEW:
+            $features_to_revert[] = $module->name;
+            break;
+        }

this seems an unneeded use of switch (which to my knowledge is a slower than a simple if).

Hm, I wonder if it also speed up if offer an option for it to gather all overridden items and then call features_revert(array(.., ...)), e.g. not call features-revert for each?

jhedstrom’s picture

Hm, I wonder if it also speed up if offer an option for it to gather all overridden items and then call features_revert(array(.., ...)), e.g. not call features-revert for each?

This would potentially be faster since calling features-revert involves a separate drush bootstrap for each feature to be reverted. However, since drush 5 supports concurrency, on a sufficiently fast machine, reverting features via drush_backend_invoke_concurrent() would probably be the fastest, but its hard to say for sure without benchmarking the 3 different approaches.

hefox’s picture

Status: Needs review » Needs work
+++ b/features.drush.inc
@@ -602,26 +602,47 @@ function drush_features_revert() {
+  foreach (features_get_features(NULL, TRUE) as $module) {

Er, is this fixing a bug? Adding the force reset of features cache

hefox’s picture

Status: Needs work » Needs review
hefox’s picture

Status: Needs review » Reviewed & tested by the community

Still curious about #9, and don't really like switch, but other than that looks good.

RTBC for 6.x and 7.x

Thanks

hefox’s picture

The same trick likely could be applied to drush_features_update_all

mpotter’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Commited 7.x version to 7ae5657.

hefox’s picture

Status: Patch (to be ported) » Needs review

This applies and good to go for 6.x if I recall correctly, but I'll verify and rtbc if so when I can

hefox’s picture

Status: Needs review » Fixed

Been running it for a while

Status: Fixed » Closed (fixed)

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