Subject: Re: [libssh2] How to increase performance of libssh2 SFTP Read/Write

Re: [libssh2] How to increase performance of libssh2 SFTP Read/Write

From: Mononen Jussi <Jussi.Mononen_at_comptel.com>
Date: Tue, 12 Jun 2007 16:09:30 +0300

>> I am reading/writing to Remote SFTP server using libssh2
>> library. However there is very poor performance compared to
>> the sftp utility comes along with UNIX.
>>
>> I am using libssh2-0.14 version.
>>
>> I tried to investigate the library and found that for Read
>> maximum packet size is 40000 bytes and for write there is a
>> loop going which will send the data in chunks of 32KB.
>>
>> I then tried to increase the SFTP Packet size by changing
>> LIBSSH2_SFTP_PACKET_MAXLEN to 64KB hoping that then we can
>> read/write in chunks of 64KB but of no use since after
>> building the library even it was not able to establish the
>> session with the remote SFTP server.
>>
>> I also tried changing various constants like
>> LIBSSH2_PACKET_MAXPAYLOAD
>> LIBSSH2_PACKET_MAXCOMP
>> LIBSSH2_PACKET_MAXDECOMP
>> LIBSSH2_CHANNEL_WINDOW_DEFAULT
>>
>> But still I was not able to increase the performance.
>>
>> Is there some way that by changing these constants or some
>> other things we can increase the performance SFTP read/write
>> using libssh2 or any other workaround so as to how to
>> increase the performance?

Hi,

maximum packet size is just the protocol (SSH2) maximum packet size. If
packet is larger than this it must be rejected, this is defined in the
SECSH RFC's (recommended maxlength is 35000 bytes). But the main problem
with read-function performance is that it reads the data in 16 byte
blocks (see packet.c line 733). This is fixed in the latest CVS version
where it reads 4096 bytes in (afaik).

Also, when comparing to command line tools (like OpenSSH sftp), libssh2
is much slower because its approach to sending/receiving is synchronous
where as the command line tools use asynchronous approach. When libssh2
sends onepacket, it can not send another before the previous one is
acknowledged. Command line tools do nothave this restriction and they
utilize the bandwidth to the maximum.

The libssh2_packet_read performance problem can be fixed easily, but the
async vs. sync transfer is a bit tougher issue to solve.

br,

/jUSSi

--
perl -e 'print for reverse @{[@{[@{[@{
[@{[Hacker,Perl,Another,Just]}]}]}]}]};'
____________________________________________________________________________________
Comptel Finland is moving to new premises. 
Starting from July 9 our new visiting address is Salmisaarenaukio 1, 00180 Helsinki,
and the postal address is P.O.Box 1000, FI-00181 Helsinki
____________________________________________________________________________________
Disclaimer: This message and any attachments thereto are intended solely for
the addressed recipient(s) and may contain confidential information. If you
are not the intended recipient, please notify the sender by reply e-mail and
delete the e-mail (including any attachments thereto) without producing,
distributing or retaining any copies thereof. Any review, dissemination or
other use of, or taking of any action in reliance upon, this information by
persons or entities other than the intended recipient(s) is prohibited.
Thank you.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
libssh2-devel mailing list
libssh2-devel_at_lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel
Received on 2007-06-12