Files

18 lines
1.3 KiB
Bash

#!/usr/bin/env bash
# OWNER-RUN (root), NOT run by agents. Runtime-only, reversible (lost at the next boot). claude/baseline-pair part e, 2026-11-02.
# Finding (M): after a reboot the page cache is cold and the NVMe (Lexar NM610PRO, /dev/nvme0n1) serves the buffered 128 KiB readahead pattern of the KAR holder and of the model
# loaders at 8-35 MB/s (iostat: r_await 4-15 ms, queue depth 1-2, 112-128 KiB requests; the holder needed 33 min to read the 55 GB KAR file), while 32 MiB O_DIRECT reads of the same
# file run at ~600 MB/s and WILLNEED readahead at 0.6-2.4 GB/s when it sticks. read_ahead_kb is 128 (mq-deadline scheduler, none for nvme). A reboot-per-run series therefore costs 40-60 min a run.
# Raising the device readahead is expected to bring the holder load and the model loads to a few minutes. It changes no data.
#
# sudo bash owner-readahead.sh show # print the current value (default action)
# sudo bash owner-readahead.sh set 4096 # runtime only; 2048-8192 are reasonable
# sudo bash owner-readahead.sh reset # back to 128
dev=/sys/block/nvme0n1/queue/read_ahead_kb
case "${1:-show}" in
show) echo "read_ahead_kb=$(cat $dev)";;
set) echo "${2:?usage: set KB}" > $dev; echo "read_ahead_kb=$(cat $dev)";;
reset) echo 128 > $dev; echo "read_ahead_kb=$(cat $dev)";;
*) echo "usage: show | set KB | reset" >&2; exit 2;;
esac