feat(storage): make per-piece writeback configurable - #2006
Merged
gaius-qi merged 5 commits intoAug 25, 2026
Merged
Conversation
cparadis-nvidia
requested review from
ClementMaH,
EvanCley,
bergwolf,
fcgxz2003,
gaius-qi and
xujihui1985
August 24, 2026 11:14
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2006 +/- ##
==========================================
+ Coverage 53.59% 53.68% +0.09%
==========================================
Files 100 100
Lines 26908 26976 +68
==========================================
+ Hits 14420 14482 +62
- Misses 12488 12494 +6
🚀 New features to boost your workflow:
|
Replace the hardcoded sync_file_range call after every piece write with a configurable WritebackMode (sync, async, off). The default mode is async, which enqueues written ranges to a background task so the write path is never stalled by disk speed. Sync preserves the old behaviour of awaiting sync_file_range inline. Off leaves dirty-page writeback entirely to the kernel thresholds. Signed-off-by: Gaius <gaius.qi@gmail.com>
Reword doc comments for `WritebackMode`, `Writeback`, and the queue capacity constant to be more accurate and concise. Signed-off-by: Gaius <gaius.qi@gmail.com>
Update all dragonfly-client crate versions from 1.5.1 to 1.5.2. Signed-off-by: Gaius <gaius.qi@gmail.com>
gaius-qi
force-pushed
the
feat/configurable-storage-writeback
branch
from
August 25, 2026 08:06
904ec94 to
ddc2320
Compare
The inline comments restated what the assertions already express clearly. Signed-off-by: Gaius <gaius.qi@gmail.com>
…ests The comment described the sleep's purpose redundantly; the code is self-explanatory without it. Signed-off-by: Gaius <gaius.qi@gmail.com>
gaius-qi
enabled auto-merge (squash)
August 25, 2026 08:10
hhhhsdxxxx
approved these changes
Aug 25, 2026
hyy0322
approved these changes
Aug 25, 2026
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.
Description
Adds a
storage.writebackconfig option that controls how the storage triggers writeback of written piece ranges:The default is
inline, so existing deployments see zero behavior change. Hosts whose download bandwidth exceeds the disk's sustained write bandwidth can opt intobackgroundand recover the full download rate (measurements in the linked issue: 0.25 → 1.07 GiB/s on a host with ~1.19 GiB/s network ingress and ~266 MiB/s NVMe).Implementation notes:
io.rs(which returns to pure I/O, no signature changes, no test churn) to the content layer, which owns both the configuration and the flusher lifecycle.backgroundmode,Content::newspawns a single flusher task fed by a small bounded channel; the write path does atry_sendand moves on. A full channel drops the hint — safe, becausesync_file_rangeis purely advisory and kernel writeback covers dropped ranges. The single consumer also means at most one blocked syscall at a time, instead of piling blocked threads onto the blocking pool at high piece rates.Contentdrops, the lastSenderdrops, the flusher'srecv()returnsNone, and the task exits.sync_file_rangewrapper is already cfg-gated to Linux).Related Issue
Fixes #2005
Motivation and Context
SYNC_FILE_RANGE_WRITEonly initiates writeback, but the syscall blocks while the device writeback queue is congested. Awaiting it inline after every piece write therefore paces the whole cold download at disk write speed on hosts where the network outruns the disk, and it flushes each range immediately, so dirty pages never accumulate and the kernelvm.dirty_*thresholds never get a chance to absorb download bursts in RAM. Full analysis, measurements, and reproduction steps are in #2005.The
backgroundmode preserves what the inline call was added for — a steady drain and bounded dirty pages while the disk keeps up — and degrades gracefully to kernel-threshold writeback when it can't, instead of pacing the download.Screenshots (if appropriate)
N/A