mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Pearce <...@google.com>
Subject sshd 0.3.0 performance regression
Date Tue, 15 Dec 2009 00:15:08 GMT
We're seeing a performance regression in SSHD 0.3.0, the throughput
is about 1/2 of what it was in SSHD 0.2.0.

Bisecting the problem in git led me to revision 882491, which was
the bug fix for https://issues.apache.org/jira/browse/SSHD-49.

Any thoughts as to why this is causing a 50% drop on throughput
from server to client?

commit 49e19df60a9d45322491dda2fc608969e6811db5
Author: Guillaume Nodet <gnodet@apache.org>
Date:   Fri Nov 20 10:48:50 2009 +0000

    SSHD-49: Fix a problem with the Output channel logic for the remote window
    
    git-svn-id: https://svn.apache.org/repos/asf/mina/sshd/trunk@882491 13f79535-47bb-0310-9956-ffa450edef68

diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelOutputStream.java
b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelOutputStream.java
index aab789a..63bcd1a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelOutputStream.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelOutputStream.java
@@ -59,17 +59,8 @@ public class ChannelOutputStream extends OutputStream {
         if (closed) {
             throw new SshException("Already closed");
         }
-        while (l > 0) {
-            int _l = Math.min(l, remoteWindow.getPacketSize() - bufferLength);
-            if (_l <= 0) {
-                flush();
-                continue;
-            }
-            buffer.putRawBytes(buf, s, _l);
-            bufferLength += _l;
-            s += _l;
-            l -= _l;
-        }
+        buffer.putRawBytes(buf, s, l);
+        bufferLength += l;
     }
 
     @Override
@@ -81,14 +72,14 @@ public class ChannelOutputStream extends OutputStream {
             while (bufferLength > 0) {
                 Buffer buf = buffer;
                 int total = bufferLength;
-                int length = Math.min(remoteWindow.waitForSpace(), total);
+                int length = Math.min(Math.min(remoteWindow.waitForSpace(), total), remoteWindow.getPacketSize());
                 int pos = buf.wpos();
                 buf.wpos(cmd == SshConstants.Message.SSH_MSG_CHANNEL_EXTENDED_DATA ? 14 :
10);
                 buf.putInt(length);
-                buf.wpos(pos);
+                buf.wpos(buf.wpos() + length);
                 newBuffer();
                 if (total > length) {
-                    buffer.putBytes(buf.array(), pos - (total - length), total - length);
+                    buffer.putRawBytes(buf.array(), pos - (total - length), total - length);
                     bufferLength = total - length;
                 }
                 remoteWindow.waitAndConsume(length);

Mime
View raw message