From 9ea45d4558f5cca3dd46b2a8f1a262cfef8cd578 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Fri, 17 Apr 2026 19:47:20 -0400 Subject: [PATCH] hardware: tighten mq-deadline read_expire for jellyfin coexistence --- modules/hardware.nix | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/hardware.nix b/modules/hardware.nix index 32ac735..81306e9 100644 --- a/modules/hardware.nix +++ b/modules/hardware.nix @@ -12,7 +12,7 @@ let parent=''${1%%[0-9]*} dev="/sys/block/$parent" [ -d "$dev/queue/iosched" ] || exit 0 - echo 15000 > "$dev/queue/iosched/read_expire" + echo 500 > "$dev/queue/iosched/read_expire" echo 15000 > "$dev/queue/iosched/write_expire" echo 128 > "$dev/queue/iosched/fifo_batch" echo 16 > "$dev/queue/iosched/writes_starved" @@ -36,11 +36,17 @@ in hardware.cpu.amd.updateMicrocode = true; hardware.enableRedistributableFirmware = true; - # HDD I/O tuning for torrent seeding workload (high-concurrency random reads). + # HDD I/O tuning for torrent seeding workload (high-concurrency random reads) + # sharing the pool with latency-sensitive sequential reads (Jellyfin playback). # # mq-deadline sorts requests into elevator sweeps, reducing seek distance. - # Aggressive deadlines (15s) let the scheduler accumulate more ops before dispatching, - # maximizing coalescence — latency is irrelevant since torrent peers tolerate 30-60s. + # read_expire=500ms keeps reads bounded so a Jellyfin segment can't queue for + # seconds behind a torrent burst; write_expire=15s lets the scheduler batch + # writes for coalescence (torrent writes are async and tolerate delay). + # The bulk of read coalescence already happens above the scheduler via ZFS + # aggregation (zfs_vdev_aggregation_limit=4M, read_gap_limit=128K, + # async_read_max=32), so the scheduler deadline only needs to be large enough + # to keep the elevator sweep coherent -- 500ms is plenty on rotational disks. # fifo_batch=128 keeps sweeps long; writes_starved=16 heavily favors reads. # 4 MiB readahead matches libtorrent piece extent affinity for sequential prefetch. #