Performance optimization for sshStorage (#313)

* Performance optimization for sshStorage

* go fmt
This commit is contained in:
İbrahim Akyel 2023-12-05 23:38:33 +03:00 committed by GitHub
parent 84990ed6bd
commit 58573e6733
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -81,7 +81,11 @@ func NewStorageBackend(opts Config, logFunc storage.Log) (storage.Backend, error
return nil, err return nil, err
} }
sftpClient, err := sftp.NewClient(sshClient) sftpClient, err := sftp.NewClient(sshClient,
sftp.UseConcurrentReads(true),
sftp.UseConcurrentWrites(true),
sftp.MaxConcurrentRequestsPerFile(64),
)
if err != nil { if err != nil {
return nil, fmt.Errorf("NewStorageBackend: error creating sftp client: %w", err) return nil, fmt.Errorf("NewStorageBackend: error creating sftp client: %w", err)
} }
@ -117,7 +121,7 @@ func (b *sshStorage) Copy(file string) error {
} }
defer destination.Close() defer destination.Close()
chunk := make([]byte, 1000000) chunk := make([]byte, 1e9)
for { for {
num, err := source.Read(chunk) num, err := source.Read(chunk)
if err == io.EOF { if err == io.EOF {