From d703ce439bc4d1141bf711f71aafddff98c963d4 Mon Sep 17 00:00:00 2001 From: MattJackson <1085847+MattJackson@users.noreply.github.com> Date: Thu, 14 May 2026 20:21:20 -0700 Subject: [PATCH] =?UTF-8?q?io/pipeline:=20bump=20WRITE=5FPIPELINE=5FDEPTH?= =?UTF-8?q?=2016=20=E2=86=92=2032?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The depth was conservative because pre-0.21.8 a full sync_file_range stall on NFS could traverse this channel and pin the producer. With 0.21.8's restored Phase 2.5 writer thread + 128 MiB byte-bounded ring inside WritebackFile, every blocking syscall happens downstream of this channel — never on it. The original "smaller buffer reduces backpressure risk" rationale no longer applies. Empirical (2026-05-15 Civil War UHD remux on 0.21.8): 30.9 MB/s sustained but instantaneous samples spanning 9-53 MB/s, stdev 9.3. Distribution clusters 52% of samples in 25-35 MB/s but has a long 9-15 MB/s tail. The tail corresponds to brief stalls in the matroska builder when the sink momentarily lags — exactly the case a deeper inter-thread channel covers. 32 frames at PES-frame sizes is still well under a megabyte of additional memory, so the cost is zero. --- src/io/pipeline.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/io/pipeline.rs b/src/io/pipeline.rs index eb9d47f..0c4baba 100644 --- a/src/io/pipeline.rs +++ b/src/io/pipeline.rs @@ -92,10 +92,16 @@ pub const DEFAULT_PIPELINE_DEPTH: usize = 4; /// consumer blocks on write. pub const READ_PIPELINE_DEPTH: usize = 32; -/// Write pipeline depth. Smaller buffer reduces backpressure risk when -/// sync_file_range blocks; prevents producer from accumulating too much -/// work while consumer waits for NFS to drain. -pub const WRITE_PIPELINE_DEPTH: usize = 16; +/// Write pipeline depth. 0.21.8 restored the writer-thread + 128 MiB +/// byte-bounded ring inside WritebackFile, which absorbs kernel +/// writeback stalls downstream of this channel. The pre-0.21.8 +/// rationale ("smaller buffer reduces backpressure risk when +/// sync_file_range blocks") no longer applies — `sync_file_range` only +/// hits the writer thread, never this channel. Doubling 16 → 32 gives +/// the matroska builder headroom to keep emitting frames when the sink +/// momentarily lags behind, smoothing out the 5-50 MB/s instantaneous +/// burst pattern observed on NFS bidirectional workloads at 0.21.8. +pub const WRITE_PIPELINE_DEPTH: usize = 32; /// Channel depth for write-through pipelines. Each `send` fully /// drains before the next can enqueue. Use this when the producer