Repository navigation
Description
The associated forum post URL from https://forum.rclone.org
What is your current rclone version (output from rclone version)?
rclone v1.65.0-beta.7391.55c3c221b.fix-b2-upload-url-lock
- os/version: ubuntu 22.04 (64 bit)
- os/kernel: 5.15.0-84-generic (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.21.1
- go/linking: static
- go/tags: none
What problem are you are trying to solve?
Rclone currently stores chunks in RAM. Recently, RAM usage increased for B2 users, when a refactor changed the RAM formula from
--transfers * --b2-chunk-size
to
--transfers * --b2-chunk-size * --b2-upload-concurrency
A possible way to reduce RAM usage across the board is to move most chunk manipulations into temporary files on disk.
How do you think rclone should be changed to solve that?
To summarize the forum post, we could add an alternative implementation of io.ReadSeeker interface, that reads disk (file handles) rather than objects in RAM.
In a more abstract framing: any chunk-data operation that writes/reads RAM could instead do so with temporary files on disk. This includes activity such as caching data coming from network, and hashing data to calculate checksums. Every chunk manipulation should be done via streaming to/from temporary files rather than RAM.
This behavior could be exposed to an end user as an option such as --low-memory or the opposite --slow-disk, depending on which mode ends up being the default.
How to use GitHub
- Please use the 👍 reaction to show that you are affected by the same issue.
- Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
- Subscribe to receive notifications on status change and new comments.
Activity
ncw commentedon Oct 3, 2023
I see 3 possible buffering schemes
RAM: Buffer in RAM like we have at the momentDisk: Buffer on disk as suggested hereNone: Don't buffer, but re-read from the source if necessary.The
b2backend only rewinds the stream if there is a retry. Retries are rare, so we could use schemeNonewhen uploading tob2. (We need a backend feature to identify this, or maybe a parameter in the chunking protocol.)If we are using
localas a source we could also useNonefor all backends as buffering to disk doesn't seem sensible when the file is on disk anyway.Exactly which scheme gets used is up for discussion, but here is my suggestion
¹ Needs performance testing to see if it slows stuff down a lot! Might need to be RAM
² It works like this at the moment as the local backend never needs retries.
Implementing the
Nonescheme requires extendingoperations.Opento into aReadSeeker. This isn't a lot of work.operations: make Open() return an io.ReadSeekCloser #7350
operations: use less memory when doing multithread uploads
ncw commentedon Oct 8, 2023
I had a go at this in the "High Memory" case above. Most transfers (which are to and from disk) won't need to use buffering any more which is a big win.
@maxim can you give this a test and see what you think?
v1.65.0-beta.7413.87aa029f5.fix-7350-multithread-memory on branch fix-7350-multithread-memory (uploaded in 15-30 mins)
maxim commentedon Oct 8, 2023
@ncw Looks like a great win in a small change! To try this, I have questions on what I should reconfigure:
--b2-upload-concurrency,--b2-chunk-size,--transfers,--multi-thread-streams).--buffer-size,--transfers,--multi-thread-streams)ncw commentedon Oct 8, 2023
Uploads from local disk to B2 shouldn't use significantly extra ram whatever the parameters.
Downloads will use --buffer-size * --transfers
Put any B2 config changes in the config file, not on the command line and it won't change the canonical name.
maxim commentedon Oct 9, 2023
Thanks for clarifications. I installed this branch without changing config for now. Will have to wait and see as more uploads take place.
ncw commentedon Oct 9, 2023
Let me know what happens!
maxim commentedon Oct 12, 2023
@ncw After 3 days of running, which included downloads and uploads, rclone seems to have been sitting at <50mb of RAM, even according to
systemctl status(which tends to show the highest RAM ever reached, or something like that). It appears so far that this is working!We could wait until I observe RAM directly during an upload. I think I caught it once, and it was still under 50mb, but not 100% sure. Would have to catch it one of these days. It has definitely uploaded stuff over 3 days, but I just haven't observed as it was happening.
operations: make Open() return an io.ReadSeekCloser #7350
operations: use less memory when doing multithread uploads
operations: make Open() return an io.ReadSeekCloser rclone#7350
operations: use less memory when doing multithread uploads