Repository navigation
local: remove fadvise calls that cause spinlock contention - #9280
Merged
Merged
Conversation
Remove the POSIX_FADV_DONTNEED and POSIX_FADV_SEQUENTIAL calls from the local backend. The DONTNEED calls cause severe spinlock contention on parallel file systems (and any system with many concurrent transfers), because each call triggers per-page cache teardown under a global lock. Observed on a 256-core system running rclone with 64 parallel transfers over Lustre: 69% of all CPU cycles were spent in kernel spinlock contention from the fadvise path, with effective throughput well below hardware capability. The kernel's own page reclaim (kswapd) handles eviction more efficiently from a single context. Since rclone does not always read files sequentially (e.g. multipart uploads rewind and re-read blocks), FADV_SEQUENTIAL was also not reliably correct. This is consistent with the non-Linux behavior (which never called fadvise) and with restic's decision to remove identical code (restic/restic#670). Fixes rclone#7886
5 tasks done
ncw
approved these changes
Mar 24, 2026
ncw
left a comment
Member
There was a problem hiding this comment.
I've been meaning to do this for ages - thank you :-)
Looks perfect. Will merge now.
zcalusic
added a commit
to zcalusic/dockerfiles
that referenced
this pull request
Mar 24, 2026
Shouldn't be needed anymore starting with v1.74.0, thanks to rclone/rclone#9280
zcalusic
added a commit
to zcalusic/dockerfiles
that referenced
this pull request
Jun 9, 2026
Shouldn't be needed anymore starting with v1.74.0, thanks to rclone/rclone#9280
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?
Remove all fadvise calls (both POSIX_FADV_DONTNEED and POSIX_FADV_SEQUENTIAL) from the local backend entirely.
The FADV_DONTNEED calls cause severe spinlock contention on parallel file systems and any system with many concurrent rclone transfers. Each DONTNEED call triggers per-page cache teardown under a global lock in the kernel. With many rclone threads calling fadvise in parallel, this becomes a catastrophic bottleneck.
Observed on a 256-core system running rclone with 64 parallel transfers over Lustre:
The kernel's own page reclaim (kswapd) handles cache eviction more efficiently from a single context rather than every rclone thread fighting over the same lock.
Since rclone does not always read files sequentially (e.g. multipart uploads rewind and re-read blocks), FADV_SEQUENTIAL was also not reliably correct.
This is consistent with the non-Linux behavior (which never called fadvise) and with restic's decision to remove the same code (restic/restic#670).
Supersedes #8723 — that PR added a flag to disable fadvise; this PR removes it outright, as discussed in the comments there.
If reviewers prefer to keep FADV_SEQUENTIAL (the readahead hint) while removing FADV_DONTNEED (the destructive one), I'm happy to adjust — but since the non-Linux path never did either, removing both seemed cleanest.
Fixes #7886
Checklist