We are running Drush in Drupal Gardens, which is a large (but not so large as to be ridiculous) multisite installation... In attempting to use Drush 3.0, we are finding that a single Drush command (on a single site) can take an incredibly long time - e.g., on the order of 20 minutes!
This appears to be due to #734270: Convenient aliases for running a command on groups of sites, which adds a scan of the sites directory to every Drush bootstrap via a call to drush_sitealias_create_sites_alias(). This can be extremely slow if you have hundreds or thousands of directories in that folder.
Since this functionality mostly only seems to be required for people who are using '@sites' on the command line or otherwise specifically requesting its use, this patch makes it so that the scan only happens in those situations. I think this makes sense, but it's possible it could cause a problem since the scan also results in populating various Drush static caches, so I'm not sure if the fact that that currently runs on every bootstrap is being relied on somewhere else. (I think probably not since the code is fairly new, but I haven't totally been able to follow the code flow here.)
Even if the patch does work correctly, it's a total hack though - so ideas for other approaches are welcome for that reason also :)
Comment | File | Size | Author |
---|---|---|---|
#8 | sites-alias-performance-2.patch | 2.75 KB | greg.1.anderson |
#5 | sites-alias-performance.patch | 2.76 KB | greg.1.anderson |
#1 | drush-avoid-expensive-sites-alias-801060-1.patch | 2.49 KB | David_Rothstein |
Comments
Comment #1
David_Rothstein CreditAttribution: David_Rothstein commentedHere is the patch.
Comment #2
moshe weitzman CreditAttribution: moshe weitzman commentedThe approach seems sound. I'm guessing that Greg has a more clever approach for detecting @sites than drush_get_context('argv')), '@sites')
Comment #3
moshe weitzman CreditAttribution: moshe weitzman commentedI guess an alternate approach is to expand the @sites alias at the time it is used, instead of inspecting the request args.
Comment #4
greg.1.anderson CreditAttribution: greg.1.anderson commentedYes, excellent suggestions. I'll work on fixing it up when I have time; maybe next week.
Comment #5
greg.1.anderson CreditAttribution: greg.1.anderson commentedTry out this patch, and see if it makes things faster for you.
drush -r /path sa @sites
anddrush sa /path/@sites
work, butdrush sa @alias/@sites
does not work. The last, though, is due to a separate issue not related to this patch (#811974: Relative aliases are broken).Comment #6
greg.1.anderson CreditAttribution: greg.1.anderson commentedI was wrong, this patch breaks relative aliases.
Comment #7
greg.1.anderson CreditAttribution: greg.1.anderson commented@David: Could you test #5 and see if it fixes your performance issues, at least? I'll keep working on the full fix.
Comment #8
greg.1.anderson CreditAttribution: greg.1.anderson commentedOkay, #5 was actually really close. Here's a patch that should actually work.
Comment #9
moshe weitzman CreditAttribution: moshe weitzman commentedMinor nit below. Otherwise RTBC.
use NULL instead of null
Powered by Dreditor.
Comment #10
greg.1.anderson CreditAttribution: greg.1.anderson commentedCommitted.
Comment #12
David_Rothstein CreditAttribution: David_Rothstein commentedTo follow up here (better late than never) - the committed patch does indeed fix the major performance issues.
We haven't tried it live yet because we are still running an older version of Drush (with the earlier patch applied).... but any patch that avoids calling drush_scan_directory() on the whole sites directory every request solves the problem - and I confirmed that this one does that :)
Thanks!