sftp: Fix upload performance issue

Since pkg/sftp 1.13.0 files were uploaded sequentially using 32kb chunks
instead of sending 64 chunks in parallel.
This commit is contained in:
Michael Eischer 2024-04-28 11:48:26 +02:00
parent faffd15d13
commit 669a669603

View file

@ -102,7 +102,10 @@ func startClient(cfg Config) (*SFTP, error) {
}()
// open the SFTP session
client, err := sftp.NewClientPipe(rd, wr)
client, err := sftp.NewClientPipe(rd, wr,
// write multiple packets (32kb) in parallel per file
// not strictly necessary as we use ReadFromWithConcurrency
sftp.UseConcurrentWrites(true))
if err != nil {
return nil, errors.Errorf("unable to start the sftp session, error: %v", err)
}
@ -359,7 +362,7 @@ func (r *SFTP) Save(_ context.Context, h backend.Handle, rd backend.RewindReader
}()
// save data, make sure to use the optimized sftp upload method
wbytes, err := f.ReadFrom(rd)
wbytes, err := f.ReadFromWithConcurrency(rd, 0)
if err != nil {
_ = f.Close()
err = r.checkNoSpace(dirname, rd.Length(), err)