diff --git a/Documentation/config-gerrit.txt b/Documentation/config-gerrit.txt index f07ac1887f..fddd9370f9 100644 --- a/Documentation/config-gerrit.txt +++ b/Documentation/config-gerrit.txt @@ -3289,6 +3289,23 @@ namespace. To alias `replication start` to `gerrit replicate`: [[sshd]] === Section sshd +[[sshd.enableCompression]]sshd.enableCompression:: ++ +In the general case, we want to disable transparent compression, since +the majority of our data transfer is highly compressed Git pack files +and we cannot make them any smaller than they already are. ++ +However, if there are CPU in abundance and the server is reachable +through slow networks, gits with huge amount of refs can benefit from +SSH-compression since git does not compress the ref announcement during +handshake. ++ +Compression can be especially useful when Gerrit slaves are being used +for the larger clones and fetches and the master server mostly takes +small receive-packs. ++ +By default, `false`. + [[sshd.backend]]sshd.backend:: + Starting from version 0.9.0 Apache SSHD project added support for NIO2 diff --git a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshDaemon.java b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshDaemon.java index 935a2905b2..577eb55b46 100644 --- a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshDaemon.java +++ b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshDaemon.java @@ -61,6 +61,7 @@ import org.apache.sshd.common.cipher.BlowfishCBC; import org.apache.sshd.common.cipher.CipherNone; import org.apache.sshd.common.cipher.TripleDESCBC; import org.apache.sshd.common.compression.CompressionNone; +import org.apache.sshd.common.compression.CompressionZlib; import org.apache.sshd.common.file.FileSystemFactory; import org.apache.sshd.common.file.FileSystemView; import org.apache.sshd.common.file.SshFile; @@ -216,6 +217,9 @@ public class SshDaemon extends SshServer implements SshInfo, LifecycleListener { final String kerberosPrincipal = cfg.getString( "sshd", null, "kerberosPrincipal"); + final boolean enableCompression = cfg.getBoolean( + "sshd", "enableCompression", false); + SshSessionBackend backend = cfg.getEnum( "sshd", null, "backend", SshSessionBackend.MINA); @@ -236,7 +240,7 @@ public class SshDaemon extends SshServer implements SshInfo, LifecycleListener { initForwarding(); initFileSystemFactory(); initSubsystems(); - initCompression(); + initCompression(enableCompression); initUserAuth(userAuth, kerberosAuth, kerberosKeytab, kerberosPrincipal); setKeyPairProvider(hostKeyProvider); setCommandFactory(commandFactory); @@ -594,13 +598,30 @@ public class SshDaemon extends SshServer implements SshInfo, LifecycleListener { new SignatureECDSA.NISTP521Factory())); } - private void initCompression() { - // Always disable transparent compression. The majority of our data - // transfer is highly compressed Git pack files. We cannot make them - // any smaller than they already are. + private void initCompression(boolean enableCompression) { + List> compressionFactories = + Lists.newArrayList(); + + // Always support no compression over SSHD. + compressionFactories.add(new CompressionNone.Factory()); + + // In the general case, we want to disable transparent compression, since + // the majority of our data transfer is highly compressed Git pack files + // and we cannot make them any smaller than they already are. // - setCompressionFactories(Arrays - .> asList(new CompressionNone.Factory())); + // However, if there are CPU in abundance and the server is reachable through + // slow networks, gits with huge amount of refs can benefit from SSH-compression + // since git does not compress the ref announcement during the handshake. + // + // Compression can be especially useful when Gerrit slaves are being used + // for the larger clones and fetches and the master server mostly takes small + // receive-packs. + + if (enableCompression) { + compressionFactories.add(new CompressionZlib.Factory()); + } + + setCompressionFactories(compressionFactories); } private void initChannels() {