Skip to content

local: add configurable I/O block size for reads and writes - #9285

Open
paf0186 wants to merge 2 commits into
rclone:masterfrom
paf0186:local-io-size
Open

paf0186 wants to merge 2 commits into
rclone:masterfrom
paf0186:local-io-size

Conversation

@paf0186

@paf0186 paf0186 commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

What is the purpose of this change?

Add --local-io-size (default 1M), --local-read-io-size, and
--local-write-io-size flags to control the I/O block size
used by the local backend.

Different storage benefits from different I/O sizes:

  • Spinning disks: larger I/O (1-4MB) reduces seeks
  • Parallel/network filesystems (Lustre, GPFS, CephFS, NFS):
    typically 1-16MB for bulk transfers
  • Some RAID controllers have sweet spots at specific sizes

The write path uses the configured size via io.CopyBuffer.
The AsyncReader gains a NewSize constructor for custom buffer
sizes, available for future read path integration.

Values must be 4K-aligned.

Fixes #9281

Note: This touches the AsyncReader in the same area as
#9284 (soft-start removal). Whichever lands first, the other
will need a trivial rebase.

@paf0186 paf0186 mentioned this pull request Mar 24, 2026
5 tasks done
@paf0186

paf0186 commented Mar 24, 2026

Copy link
Copy Markdown
Contributor Author

Note: this touches the same AsyncReader code as #9284 (soft-start removal). They're independent changes — whichever lands first, the other will need a trivial rebase.

@paf0186

paf0186 commented Mar 24, 2026

Copy link
Copy Markdown
Contributor Author

#9286 (O_DIRECT support) is based on this PR. They can be reviewed independently but #9286 will need a rebase if this lands first (or vice versa).

paf0186 added 2 commits March 24, 2026 12:23
The write path was allocating a fresh buffer with make() for
every file written, then relying on GC to clean it up. The
read path already uses a buffer pool (via AsyncReader) for
reuse and memory tracking.

Use pool.Global() for write buffers too, so they are reused
across transfers and tracked by the memory limiter.

Signed-off-by: Patrick Farrell <[email protected]>
Add --local-io-size (default 1M), --local-read-io-size, and
--local-write-io-size flags to control the I/O block size
used by the local backend. Values must be 4K-aligned.

The write path uses pool.GlobalWithSize() to get a properly
sized buffer from a per-size pool, so custom sizes still get
buffer reuse and memory tracking.

The pool gains GlobalWithSize() which returns the default
global pool for the default 1MB size, or creates and caches
a new pool for other sizes.

The AsyncReader gains a NewSize() constructor that uses a
matching pool, so custom read buffer sizes also get proper
pool integration.

Fixes: rclone#9281

Signed-off-by: Patrick Farrell <[email protected]>
@ncw

ncw commented Mar 24, 2026

Copy link
Copy Markdown
Member

Do you have some benchmarks for this? before, after with 1MB, after with 16MB etc. That would be useful to know!

@ncw

ncw commented Mar 24, 2026

Copy link
Copy Markdown
Member

I note you have two PRs with almost the same name which is confusing me :-)

@paf0186

paf0186 commented Mar 24, 2026

Copy link
Copy Markdown
Contributor Author

Really? There's direct IO and block size, is there one I'm missing? 😀

They are closely related, I admit!

I'll comment on perf numbers in a bit, thanks!

@paf0186

paf0186 commented Mar 24, 2026 •

Copy link
Copy Markdown
Contributor Author

OK, so perf numbers are a little tough. It depends a lot on context, and it's partly connected to the direct IO feature.

For Lustre (which is just a regular POSIX fs on Linux), the default 1 MiB reads/writes are enough to ~saturate if you're using buffered IO - you'll get 1.5-2.5 GiB/s thread depending on various details. I think 1 MiB is generally good for most file systems.

But for direct IO, if you can use larger sizes, you get much higher speeds on Lustre, and on various other ones as well, though not as dramatically.

Here's a graph of single threaded write performance with IO size on Lustre - read is similar. As you can see, it's as much 10-15x higher at the extreme end, and pretty good lower down.

image

But it's also just generally a configurability thing - it lets people optimize. A lot of file copy utilities support it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

local: add configurable I/O block size for local filesystem reads/writes

2 participants