ssh: enable compression by default

Using the same test as in 7af97c0365,
transmitted wire bytes drops from 135,531 to 133,071 (-1.81%), while
received drops from 21,073 to 14,775 (-30%).

Combined, both changes shave 13,914 bytes (-8.6%) off aggregate
bandwidth usage.

Make it configurable as compression hurts in some scenarios.
wip-fakessh-exit-status
David Wilson 6 years ago
parent ccd9c62399
commit bdd8648bae

@ -562,7 +562,7 @@ Router Class
a password is requested, :py:class:`mitogen.sudo.PasswordError` is
raised.
.. method:: ssh (hostname, username=None, ssh_path=None, port=None, check_host_keys=True, password=None, identity_file=None, \**kwargs)
.. method:: ssh (hostname, username=None, ssh_path=None, port=None, check_host_keys=True, password=None, identity_file=None, compression_level=6, \**kwargs)
Arrange for a context to be constructed over a ``ssh`` invocation. The
``ssh`` process is started in a newly allocated pseudo-terminal, and
@ -594,6 +594,10 @@ Router Class
the SSH client to perform authenticaion; agent authentication is
automatically disabled, as is reading the default private key from
``~/.ssh/id_rsa``, or ``~/.ssh/id_dsa``.
:param int compression_level:
Integer 0-9 representing the zlib compression level to use on the
connection, with 0 indicating compression is disabled. Defaults to
6.
Context Class

@ -59,7 +59,7 @@ class Stream(mitogen.parent.Stream):
def construct(self, hostname, username=None, ssh_path=None, port=None,
check_host_keys=True, password=None, identity_file=None,
**kwargs):
compression_level=6, **kwargs):
super(Stream, self).construct(**kwargs)
self.hostname = hostname
self.username = username
@ -67,6 +67,7 @@ class Stream(mitogen.parent.Stream):
self.check_host_keys = check_host_keys
self.password = password
self.identity_file = identity_file
self.compression_level = compression_level
if ssh_path:
self.ssh_path = ssh_path
@ -82,6 +83,11 @@ class Stream(mitogen.parent.Stream):
bits += ['-o', 'IdentitiesOnly yes']
if self.identity_file:
bits += ['-i', self.identity_file]
if self.compression_level:
bits += [
'-o', 'Compression yes',
'-o', 'CompressionLevel %d' % (self.compression_level,)
]
if not self.check_host_keys:
bits += [
'-o', 'StrictHostKeyChecking no',

Loading…
Cancel
Save