deploy_chrome: Add --compress=always,never,auto option
edcourtney@ found that deploy_chrome is much faster without
--compress for rsync when using a USB 3.0 gigabit dongle.
This patch adds --compress option which can be used to
specify the compression behavior. The default is set to 'auto'
which disables compression if the target device has a gigabit
ethernet port.
BUG=734452
TEST=Ran deploy_chrome with --compress=always,never,auto and confirm that the flag works as intended:
- The target directory on the device is wiped every time
- The host workstation is Z840, and the target device is chell
% deploy_chorme --nostrip --compress=always ...
12:41:34: INFO: Using rsync compression: True
real 0m47.873s
% deploy_chorme --nostrip --compress=never ...
12:43:46: INFO: Using rsync compression: False
real 0m26.573s
% deploy_chorme --nostrip --compress=auto ...
12:44:36: INFO: Using rsync compression: False
real 0m26.237s
Change-Id: Ia617df609fc76600faaecfbe05e42ab815a6a91d
Reviewed-on: https://chromium-review.googlesource.com/541096
Commit-Ready: Satoru Takabayashi <satorux@google.com>
Tested-by: Satoru Takabayashi <satorux@google.com>
Reviewed-by: Ilja H. Friedel <ihf@chromium.org>
diff --git a/scripts/deploy_chrome.py b/scripts/deploy_chrome.py
index e4f05b1..e9b3d32 100644
--- a/scripts/deploy_chrome.py
+++ b/scripts/deploy_chrome.py
@@ -245,6 +245,15 @@
logging.warning('The device has less than 100MB free. deploy_chrome may '
'hang during the transfer.')
+ def _ShouldUseCompression(self):
+ """Checks if compression should be used for rsync."""
+ if self.options.compress == 'always':
+ return True
+ elif self.options.compress == 'never':
+ return False
+ elif self.options.compress == 'auto':
+ return not self.device.HasGigabitEthernet()
+
def _Deploy(self):
old_dbus_checksums = self._GetDBusChecksums()
@@ -260,6 +269,7 @@
self.device.CopyToDevice('%s/' % os.path.abspath(self.staging_dir),
self.options.target_dir,
mode='rsync', inplace=True,
+ compress=self._ShouldUseCompression(),
debug_level=logging.INFO,
verbose=self.options.verbose)
@@ -484,6 +494,11 @@
# is used as-is, and not normalized. Used by the Chrome ebuild to skip
# fetching the SDK toolchain.
parser.add_argument('--strip-bin', default=None, help=argparse.SUPPRESS)
+ parser.add_argument('--compress', action='store', default='auto',
+ choices=('always', 'never', 'auto'),
+ help='Choose the data compression behavior. Default '
+ 'is set to "auto", that disables compression if '
+ 'the target device has a gigabit ethernet port.')
return parser