Skip to content

local: remove soft-start logic from AsyncReader #9282

Open

Description

@paf0186

What is the problem you are having with rclone?

The AsyncReader in fs/asyncreader/asyncreader.go uses a
"soft-start" that begins reads at 4KB and doubles each read
until reaching the full 1MB buffer size. This means every
file transfer begins with 9 undersized reads (4K, 8K, 16K,
32K, 64K, 128K, 256K, 512K, then 1MB) before reaching full
I/O size.

This doesn't serve a useful purpose:

  • The 1MB buffer is already allocated from the pool. The
    soft-start just slices it smaller with b.buf[:a.size],
    so it doesn't save memory.
  • For small files, the kernel handles this naturally — if
    you read(fd, buf, 1MB) on a 3KB file, you get 3KB back.
    There's no penalty for asking for more than the file
    contains.
  • Each read is a syscall with fixed overhead (context
    switch, VFS path walk, filesystem locking). The 9 extra
    undersized reads add pure overhead for no benefit.
  • For large files, the ramp-up is just wasted I/O. A 1GB
    transfer does its first ~2MB through 9 small reads before
    reaching full speed.

How do you think rclone should be changed?

Remove the soft-start logic and always use the full buffer
size from the first read. The relevant code is in
fs/asyncreader/asyncreader.go:

// Current: starts at 4KB, doubles to 1MB
a.size = softStartInitial // 4KB

// In the read loop:
if a.size < BufferSize {
    b.buf = b.buf[:a.size]
    a.size <<= 1
}

This should just use the full buffer unconditionally.

If a configurable I/O block size is added (#9281), the
soft-start should definitely not be fighting the user's
explicitly chosen I/O size.

Activity

  1. added a commit that references this issue on Mar 24, 2026
    3a34f9e
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