Pass 1 sweep speed on a healthy disc previously dipped from ~15 MB/s to ~1 MB/s every ~30 s on a host with default Linux dirty-page settings. Empirical cause: the kernel's vm.dirty_ratio (~20% of RAM) lets hundreds of MB of dirty pages accumulate, then bursts a flush at 99% disk utilisation that blocks app writes for ~1 s. Confirmed on the BU40N test bed — dirty pages grew 112 → 563 MB between bursts; lowering vm.dirty_bytes to 64 MB at the host sysctl level eliminated the dips. Shipping the equivalent inside libfreemkv so users do not need to tune the host kernel. - New crate::io::Writer: drop-in File wrapper (impl Write + Seek). Wraps a per-platform WritebackPipeline that on Linux schedules sync_file_range(WRITE) + lagging sync_file_range(WAIT_AFTER) + posix_fadvise(DONTNEED) in 32 MB chunks, bounding dirty cache at ~64 MB. macOS and Windows ship a no-op stub. - Disc::sweep wraps its output File in Writer. Loop body unchanged. - Module is purpose-built so any large sequential output (patch, mux) can adopt the same wrapper as a one-line change later.
18 lines
581 B
Rust
18 lines
581 B
Rust
//! Per-platform writeback pipeline. On Linux, drains dirty pages
|
|
//! continuously at chunk granularity to keep the kernel's writeback
|
|
//! queue bounded. On macOS and Windows, a no-op stub.
|
|
//!
|
|
//! The platform decision lives entirely in this file (the cfg-gated
|
|
//! `pub use` below). Callers — and `DiskWriter` itself — are
|
|
//! platform-independent.
|
|
|
|
#[cfg(target_os = "linux")]
|
|
mod linux;
|
|
#[cfg(not(target_os = "linux"))]
|
|
mod noop;
|
|
|
|
#[cfg(target_os = "linux")]
|
|
pub(super) use linux::WritebackPipeline;
|
|
#[cfg(not(target_os = "linux"))]
|
|
pub(super) use noop::WritebackPipeline;
|