From 78120d40d9bd5171d58aa4839c4766a4eaef4461 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 28 Mar 2022 12:57:34 +0100 Subject: [PATCH] sftp: add --sftp-concurrency to improve high latency transfers See: https://forum.rclone.org/t/increasing-sftp-transfer-speed/29928 --- backend/sftp/sftp.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend/sftp/sftp.go b/backend/sftp/sftp.go index ae617069d..a228dece1 100644 --- a/backend/sftp/sftp.go +++ b/backend/sftp/sftp.go @@ -292,6 +292,16 @@ a large file, try lowering this number. `, Default: 32 * fs.Kibi, Advanced: true, + }, { + Name: "concurrency", + Help: `The maximum number of outstanding requests for one file + +This controls the maximum number of outstanding requests for one file. +Increasing it will increase throughput on high latency links at the +cost of using more memory. +`, + Default: 64, + Advanced: true, }}, } fs.Register(fsi) @@ -325,6 +335,7 @@ type Options struct { DisableConcurrentWrites bool `config:"disable_concurrent_writes"` IdleTimeout fs.Duration `config:"idle_timeout"` ChunkSize fs.SizeSuffix `config:"chunk_size"` + Concurrency int `config:"concurrency"` } // Fs stores the interface to the remote SFTP files @@ -503,6 +514,7 @@ func (f *Fs) newSftpClient(conn *ssh.Client, opts ...sftp.ClientOption) (*sftp.C sftp.UseConcurrentReads(!f.opt.DisableConcurrentReads), sftp.UseConcurrentWrites(!f.opt.DisableConcurrentWrites), sftp.MaxPacketUnchecked(int(f.opt.ChunkSize)), + sftp.MaxConcurrentRequestsPerFile(f.opt.Concurrency), ) return sftp.NewClientPipe(pr, pw, opts...) }