Skip to content

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

Open

Description

@paf0186

What problem are you trying to solve?

The local backend's I/O block size is hardcoded at 1MB
(pool.BufferSize in lib/pool/pool.go). There's no way to
tune this for different storage systems.

1MB is a reasonable default for local SSDs, but different
storage benefits from different I/O sizes:

  • Spinning disks: larger I/O (1-4MB) reduces seeks and
    amortizes rotational latency
  • Parallel/network filesystems (Lustre, GPFS, CephFS, NFS):
    optimal I/O size depends on stripe size and network MTU;
    typically 1-16MB for bulk transfers
  • Some RAID controllers and storage appliances have sweet
    spots at specific I/O sizes

How do you think rclone should be changed?

Add flags to control the I/O size used for local backend
reads and writes:

  • --local-io-size — sets both read and write I/O size
    (default 1M, preserving current behavior)
  • --local-read-io-size — override for reads only
  • --local-write-io-size — override for writes only

The per-direction flags override --local-io-size when set,
allowing independent tuning (e.g., large reads with smaller
writes, or vice versa).

These would feed into the AsyncReader's buffer size for reads
(currently hardcoded as pool.BufferSize = 1MB), and control
the write buffer size passed through io.Copy / WriteTo.

Values must be 4K-aligned (enforced at flag parse time). The
flags accept standard size suffixes (e.g., 1M, 4M, 16M).

Activity

  1. paf0186 commented on Mar 24, 2026

    @paf0186
    ContributorAuthor

    PR #9285 addresses this. While working on it, I noticed the write path in the local backend was allocating a fresh buffer with make() for every file write and relying on GC to clean it up, while the read path already uses a buffer pool for reuse and memory tracking.

    The first commit in the PR fixes that — writes now use pool.Global() too. The second commit adds the configurable I/O size flags, with pool.GlobalWithSize() so custom sizes also get proper pool integration.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions