Subject: [libssh2] sftp performance

[libssh2] sftp performance

From: Peter O'Gorman <>
Date: Mon, 13 Aug 2007 12:12:36 -0500


Wondering about the speed differential between scp and sftp with
libssh2, I built a profile version (--disable-shared CFLAGS="-pg") to
see if anything obvious jumped out at me...

The main thing that does jump out (comparing scp_nonblock and
sftp_nonblock in examples/simple) is that sftp makes many more calls
to libssh2_packet_read than scp - about 10 times as many. This can be
reduced by using a larger buffer, I tried 4Kb, 16Kb and 32Kb and saw
improvements for each, but still, for a large file from localhost, an
scp copy is 4 times faster than an sftp copy (it makes 4 times as many
calls to libssh2_packet_read), enlarging the buffer again (128Kb now)
makes sftp faster than scp.

This proves, yet again, that larger reads are better, and shows that
libssh2 is not, in fact, slow at sftp transfers.


Thank you,

Unchanged scp_nonblock
real 0m19.600s
user 0m5.622s
sys 0m5.709s

1Kb buffer (i.e. unchanged) sftp_nonblock
(no times, because I control-Ced after 10 minutes)

32Kb buffer - sftp_nonblock
real 1m22.487s
user 0m21.022s
sys 0m54.886s

128Kb buffer - sftp_nonblock
real 0m7.775s
user 0m2.431s
sys 0m3.637s

This email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>
libssh2-devel mailing list
Received on 2007-08-13