Chirag
Chirag

Reputation: 259

How to increase performance of libssh2 NMSSH Framework ios

I am using NMSSH Framework version 2.2.0 to download files from the server. I found that the file chunk size is fixed to 2000 bytes libssh2_sftp_read() this method returns the fixed size. I have tried increasing buffer size but it will not increase the chunk read size. I want to increase the performance of the framework by increasing the Chunk size.

Upvotes: 3

Views: 687

Answers (2)

Dale
Dale

Reputation: 3323

Although the body of the question specifically asks about changing the libssh2 chunk size the headline of the question still comes up as a top result in Google when searching for NMSSH performance.

So to answer the headline question:

Rather than having to rebuild libssh2, I found the following simple steps to improve the performance of NMSSH. Turn on compression:

   libssh2_session_flag(sshSession.session, LIBSSH2_FLAG_COMPRESS, 1)

where sshSession is an instance NMSSHSession (In Objective-C the getter is rawSession).

And in addition for NMSFTP increase the default buffer size from 16k to 128k:

    sftpSession.bufferSize = 128 * 1024

where sftpSession is an instance of NMSFTP

Upvotes: 1

Chirag
Chirag

Reputation: 259

I have found a way to increase the chunk size. The chunk size is hard coded in the libssh2 library you have to download the source code from the libssh2 site and then edit the constant given in the sftp.h file i.e. #SFTP_READ_SIZE 8000 or the size you want but make sure it should not be more than your buffer size.

Then rebuild the library.

Upvotes: 2

Related Questions