Repository navigation
Conversation
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]>
paf0186
force-pushed
the
local-direct-io
branch
from
March 24, 2026 16:29
b61440c to
6ab03c2
Compare
Add --local-direct-io flag that opens files with O_DIRECT for writes, bypassing the kernel page cache. This avoids polluting the page cache with single-use streaming data on large transfers. O_DIRECT requires aligned I/O buffers and sector-aligned write sizes. The implementation uses 4K-aligned buffer allocation and drops O_DIRECT via fcntl for the final partial block of each file. Falls back to buffered I/O with a warning if O_DIRECT open fails (e.g., filesystem doesn't support it). Read path O_DIRECT is not yet implemented — it requires aligned buffers in the accounting/async reader layer. Linux only for now. Fixes: rclone#9283 Signed-off-by: Patrick Farrell <[email protected]>
paf0186
force-pushed
the
local-direct-io
branch
from
March 24, 2026 17:05
6ab03c2 to
53cd5f5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of this change?
Add
--local-direct-ioflag that opens files with O_DIRECT forwrites, bypassing the kernel page cache. This avoids polluting
the page cache with single-use streaming data on large transfers.
This is a performance option, not a durability guarantee. Use cases:
pollution from rclone displaces other workloads' data
transfers
Implementation details:
file (O_DIRECT requires sector-aligned write sizes)
fails
buffers in the accounting/async reader layer)
Fixes #9283
Note: This PR is based on #9285 (configurable I/O block size)
and will need a rebase depending on which lands first. They can
also be reviewed independently — the O_DIRECT commit is separate
from the I/O size commit.