What is your input stream reading from ? It is a local file ?
There's still an issue in UploadFile where our buffer size is automatically reduce to the size of the last read.
Assume we start with a buffer size of 32 KB (this depends on SftpClient.BufferSize and the maximum packet size of the remote channel).
Now if we attempt to read 32 KB from the input stream, but the stream only provide 1 KB.
Then we'll adjust the buffer size we use to 1 KB, which means that for the next "chunk" we'll only attempt to read 1 KB (instead of 32 KB).
I'm not saying that you're running into this, but it's worth considering.
There are still other performance optimizations possible in UploadFile, but I haven't had time yet.
As always:
It help me a lot if you could reproduce this using a public SSH server, or if you could grant me access to the server you're using (but I understand this is hard to sell).
There's still an issue in UploadFile where our buffer size is automatically reduce to the size of the last read.
Assume we start with a buffer size of 32 KB (this depends on SftpClient.BufferSize and the maximum packet size of the remote channel).
Now if we attempt to read 32 KB from the input stream, but the stream only provide 1 KB.
Then we'll adjust the buffer size we use to 1 KB, which means that for the next "chunk" we'll only attempt to read 1 KB (instead of 32 KB).
I'm not saying that you're running into this, but it's worth considering.
There are still other performance optimizations possible in UploadFile, but I haven't had time yet.
As always:
It help me a lot if you could reproduce this using a public SSH server, or if you could grant me access to the server you're using (but I understand this is hard to sell).