5881ed4
From 0a758095c40ae1b32dc5052a706a16c2d9ac5742 Mon Sep 17 00:00:00 2001
5881ed4
From: Salvador Fandino <sfandino@yahoo.com>
5881ed4
Date: Mon, 21 Oct 2013 11:58:55 +0200
5881ed4
Subject: [PATCH 10/11] Set default window size to 2MB
5881ed4
5881ed4
The default channel window size used until now was 256KB. This value is
5881ed4
too small and results on a bottleneck on real-life networks where
5881ed4
round-trip delays can easily reach 300ms.
5881ed4
5881ed4
The issue was not visible because the configured channel window size
5881ed4
was being ignored and a hard-coded value of ~22MB being used instead,
5881ed4
but that was fixed on a previous commit.
5881ed4
5881ed4
This patch just changes the default window size
5881ed4
(LIBSSH2_CHANNEL_WINDOW_DEFAULT) to 2MB. It is the same value used by
5881ed4
OpenSSH and in our opinion represents a good compromise between memory
5881ed4
used and transfer speed.
5881ed4
5881ed4
Performance tests were run to determine the optimum value. The details
5881ed4
and related discussion are available from the following thread on the
5881ed4
libssh2 mailing-list:
5881ed4
5881ed4
http://www.libssh2.org/mail/libssh2-devel-archive-2013-10/0018.shtml
5881ed4
http://article.gmane.org/gmane.network.ssh.libssh2.devel/6543
5881ed4
5881ed4
An excerpt follows:
5881ed4
5881ed4
"I have been running some transfer test and measuring their speed.
5881ed4
5881ed4
My setup was composed of a quad-core Linux machine running Ubuntu 13.10
5881ed4
x86_64 with a LXC container inside. The data transfers were performed
5881ed4
from the container to the host (never crossing through a physical
5881ed4
network device).
5881ed4
5881ed4
Network delays were simulated using the tc tool. And ping was used to
5881ed4
verify that they worked as intended during the tests.
5881ed4
5881ed4
The operation performed was the equivalent to the following ssh command:
5881ed4
5881ed4
  $ ssh container "dd bs=16K count=8K if=/dev/zero" >/dev/null
5881ed4
5881ed4
Though, establishment and closing of the SSH connection was excluded
5881ed4
from the timings.
5881ed4
5881ed4
I run the tests several times transferring files of sizes up to 128MB
5881ed4
and the results were consistent between runs.
5881ed4
5881ed4
The results corresponding to the 128MB transfer are available here:
5881ed4
5881ed4
https://docs.google.com/spreadsheet/ccc?key=0Ao1yRmX6PQQzdG5wSFlrZl9HRWNET3ZyN0hnaGo5ZFE&usp=sharing
5881ed4
5881ed4
It clearly shows that 256KB is too small as the default window size.
5881ed4
Moving to a 512MB generates a great improvement and after the 1MB mark
5881ed4
the returns rapidly diminish. Other factors (TCP window size, probably)
5881ed4
become more limiting than the channel window size
5881ed4
5881ed4
For comparison I also performed the same transfers using OpenSSH. Its
5881ed4
speed is usually on par with that of libssh2 using a window size of 1MB
5881ed4
(even if it uses a 2MB window, maybe it is less aggressive sending the
5881ed4
window adjust msgs)."
5881ed4
5881ed4
Signed-off-by: Salvador Fandino <sfandino@yahoo.com>
5881ed4
5881ed4
[upstream commit 85a827d1bceb9abd4442f225dd7c65ef5cefdc32]
5881ed4
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
5881ed4
---
5881ed4
 include/libssh2.h |    2 +-
5881ed4
 1 files changed, 1 insertions(+), 1 deletions(-)
5881ed4
5881ed4
diff --git a/include/libssh2.h b/include/libssh2.h
5881ed4
index 9b1a6e1..df873fc 100644
5881ed4
--- a/include/libssh2.h
5881ed4
+++ b/include/libssh2.h
5881ed4
@@ -587,7 +587,7 @@ LIBSSH2_API int libssh2_poll(LIBSSH2_POLLFD *fds, unsigned int nfds,
5881ed4
                              long timeout);
5881ed4
 
5881ed4
 /* Channel API */
5881ed4
-#define LIBSSH2_CHANNEL_WINDOW_DEFAULT  (256*1024)
5881ed4
+#define LIBSSH2_CHANNEL_WINDOW_DEFAULT  (2*1024*1024)
5881ed4
 #define LIBSSH2_CHANNEL_PACKET_DEFAULT  32768
5881ed4
 #define LIBSSH2_CHANNEL_MINADJUST       1024
5881ed4
 
5881ed4
-- 
5881ed4
1.7.1
5881ed4