Raspberry Pi 3 Model B
Raspbian GNU/Linux 10 (buster) / Linux raspberrypi 4.19.75-v7+
I tried downloading a file from SFTP remote - the download speed keeps going down endlessly right from the start, and the actual download progress never gets past several megabytes.
I tested the download speed with wget and some random file from the internet - it downloads at maximum speed (what I have from my ISP). Also tested with default sftp utility and the same remote (which I tried with rclone) - same thing, the download goes at maximum speed. So it seems that it's rclone issue.
What's peculiar, I was using rclone on the same Raspberry Pi unit before but with different Linux distribution - LibreELEC - and I did not have this issue, downloads were going at maximum speed.
So I assume there should be something different about Raspbian environment, which causes this issue. Does anyone know what can be done in this regard?
Another thing I noticed: when I press Ctrl + C to cancel the transfer, it takes a really long time till the operation actually stops and I get my prompt back. Feels like it stops a lot of spawned threads or something like that.
Oh well, right after writing about threads, I went to read the rclone documentation to look for a similar option just in case. And indeed, there is such option - setting --multi-thread-streams 1 resolved the issue, downloads go at the maximum speed now.
P.S. At the same time, here's what I see at htop (that's already with --multi-thread-streams 1):
What was the remote server? --multi-thread-streams should work for all servers. Can you try an experiment and see if it does complete? Maybe you could run it on a small file by setting --multi-thread-cutoff 10M and see if it does ever complete?
You are seeing rclone copying multiple files at once with --transfers and reading multiple directories at once with --checkers.
Go uses lightweight threads call goroutines which don't map 1:1 with OS threads - you'll typically get the same number of threads as CPUs more or less (there can be more if go has to do lots of system calls, eg local IO).
I was just wondering if you knew what the server is?
Indeed! Rclone will be doing hashing the file contents in a different thread, ssh encryption, file io all in different threads probably. It still looks like too many threads actually doing stuff though!
I've checked just now, the server seems to report the following: SSH-2.0-mod_sftp/0.9.9. But when I was using rclone on LibreELEC, I was working with the same server, and I didn't have this issue back then, so I doubt that it's related to the server.
If you would like to and if you have some test servers available, I can test it with those.