baseline-pair part e: reboot-per-run series stopped after cycle 1 (cold-read cost), fresh-boot vanilla finding, owner readahead script

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Pavlo Ratushnyi
2026-11-02 01:27:05 +01:00
co-authored by Claude Sonnet 5.5
parent ca3eb4f8fa
commit 535087e04a
4 changed files with 62 additions and 3 deletions
+20
View File
@@ -8,6 +8,26 @@ costs about an hour of cold loading. The reads change no data; the page cache en
import mmap, os, sys, time
W = 1 << 30
AHEAD = 3
def shmem_bytes():
for ln in open("/proc/meminfo"):
if ln.startswith("Shmem:"):
return int(ln.split()[1]) * 1024
return 0
if sys.argv[1] == "--follow":
# --follow FILE READYFILE : the holder reads FILE sequentially into a memfd (Shmem grows with its position); keep 8 GiB of FILE ahead of that position in the page cache until
# READYFILE exists. Needed because the pages read ahead by a plain pre-read are partly evicted again before the holder gets to them.
path, ready = sys.argv[2], sys.argv[3]
size = os.path.getsize(path); fd = os.open(path, os.O_RDONLY); base = shmem_bytes(); t0 = time.time()
while not (os.path.exists(ready) and os.path.getsize(ready) > 0) and time.time() - t0 < 3600:
cur = max(0, shmem_bytes() - base)
lo = max(0, cur - (64 << 20)); hi = min(size, cur + (8 << 30))
if hi > lo:
os.posix_fadvise(fd, lo, hi - lo, os.POSIX_FADV_WILLNEED)
time.sleep(0.5)
print("follow %s done after %.0f s" % (path, time.time() - t0), flush=True)
sys.exit(0)
def files(args):
for a in args:
if os.path.isdir(a):
+3 -3
View File
@@ -2,7 +2,7 @@
# baseline-pair part e: ONE ARM PER FRESH BOOT. Runs on the LAPTOP (git bash), drives rnr5090 over ssh. Owner-authorised (chat, 2026-11-01): rebooting rnr5090 between runs.
# Allowed on the server: `sudo -n systemctl reboot` and nothing else privileged (no systemd units, sysctl, grub; sudo -n dmesg is read-only).
#
# bash baseline-reboot-series.sh [BLOCKS="1 2 3 4 5 6"] env: SERIES_LOG (local log), STOPFILE (touch it to stop after the current cycle)
# [START_CYCLE=2] bash baseline-reboot-series.sh [BLOCKS="1 2 3 4 5 6"] env: SERIES_LOG (local log), STOPFILE (touch it to stop after the current cycle), START_CYCLE (resume)
#
# Per cycle: (1) nothing foreign may run (jobs pending/running other than our stubs, gpu.lock, a GPU process); wait otherwise, never reboot under a job;
# (2) `sync`, reboot, wait for ssh (new boot_id) up to 10 min; on timeout try the rescue sshd (:2222, `rboot`) once, then STOP; (3) safety net check (rescue sshd :2222, /dev/watchdog0,
@@ -94,8 +94,8 @@ for b in $BLOCKS; do
# KAR holder, as after the boot of 2026-10-29 (notes.md): stale empty MODEL.lock removed, ONE holder started, READY rewritten
$SSH 'pgrep -f "[k]ar_holder2" >/dev/null && echo HOLDER_ALREADY_RUNNING; rm -f '"$JOBS"'/READY; [ -d $HOME/work/gpu-runs/MODEL.lock ] && { rmdir $HOME/work/gpu-runs/MODEL.lock || echo MODEL_LOCK_NOT_EMPTY; }
cd $HOME/work/gpu-runs/holder2 && { setsid nohup bash run_holder2.sh >> holder2.out 2>&1 < /dev/null & } ; sleep 1; echo started' | while read -r l; do log "holder: $l"; done
for _ in $(seq 1 150); do $SSH 'test -s '"$JOBS"'/READY' 2>/dev/null && break; sleep 10; done
$SSH 'test -s '"$JOBS"'/READY' || die "KAR holder not READY within 15 min"
for _ in $(seq 1 480); do $SSH 'test -s '"$JOBS"'/READY' 2>/dev/null && break; sleep 10; done
$SSH 'test -s '"$JOBS"'/READY' || die "KAR holder not READY within 90 min"
log "holder READY: $($SSH 'cat '"$JOBS"'/READY; echo " uptime_s=$(cut -d" " -f1 /proc/uptime)"')"
f=$(foreign | grep -v '^proc:' | tr '\n' ' ')
if [ -n "${f// /}" ]; then log "foreign work appeared after boot ($f): waiting for it, then redoing the reboot for a fresh state"; wait_quiet; continue; fi
+17
View File
@@ -0,0 +1,17 @@
#!/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