You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
local: remove soft-start logic from AsyncReader #9282
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 1MBa.size=softStartInitial// 4KB// In the read loop:ifa.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
asyncreader: remove soft-start logic