27 lines
2.4 KiB
Bash
27 lines
2.4 KiB
Bash
#!/usr/bin/env bash
|
|
# Prefill fixed-latency program: restart the lab holder with a SPARSE sealed memfd and record what it frees.
|
|
# A holder-free window started DETACHED by a queue stub that has touched jobs/STOP and closed the holder's descriptor. Test tooling, never in serving. pf_holder_window.sh LABEL [full]
|
|
# 1. waits until the lab holder has ended and its memfd is gone; 2. records the host memory (before); 3. starts the holder with the sparse seal (the `full` argument: the old full copy);
|
|
# 4. waits for jobs/READY and records the host memory (after) and the holder's `ready ... allocated=` line. Records: $PL/runs/holder/LABEL.txt, notes.md.
|
|
set -u
|
|
LABEL=${1:-holder}; FORM=${2:-sparse}
|
|
PL=/data/leleka-e2e/prefill-latency
|
|
H=$HOME/work/gpu-runs/holder2
|
|
NOTES=/data/leleka-e2e/decode/notes.md
|
|
OUT=$PL/runs/holder; mkdir -p "$OUT"
|
|
note() { echo "[$(date -u +%FT%TZ)] [DEV prefill-latency] $*" >> "$NOTES"; }
|
|
snap() { echo "== $1 $(date -u +%FT%TZ)"; grep -E '^(MemTotal|MemFree|MemAvailable|Cached|Shmem|AnonPages|Mapped):' /proc/meminfo; head -2 /proc/pressure/memory; grep -E '^(allocstall_normal|allocstall_movable|pgscan_direct|compact_stall|workingset_refault_file) ' /proc/vmstat; }
|
|
holder_up() { pgrep -u "$USER" -f 'kar_holder2?\.py|single-copy-holder\.py' >/dev/null; }
|
|
note "holder window $LABEL: waiting for the holder to end (jobs/STOP is set), then a $FORM holder"
|
|
for _ in $(seq 1 1440); do if ! holder_up && [ ! -d "$HOME/work/gpu-runs/MODEL.lock" ]; then break; fi; sleep 5; done
|
|
if holder_up; then note "holder window $LABEL: the holder did not end in 2 h, giving up"; exit 3; fi
|
|
sleep 5
|
|
{ snap before; } >"$OUT/$LABEL.txt" 2>&1
|
|
rm -f "$H/jobs/STOP" "$H/jobs/READY"
|
|
( cd "$H" && unset CMP_ARM CMP_TASKS CMP_OPTIONAL CMP_REPS CMP_VANILLA_LOSSY CMP_WALL CMP_ROUNDS CMP_RUN CMP_TARBALL PF_VAR PF_ENV PF_REPS PF_TASKS PF_RUN \
|
|
&& HOLDER_MEMFD=$FORM setsid nohup bash "$PL/tools/pf_holder_sparse.sh" > "$H/holder3.out" 2>&1 < /dev/null & )
|
|
for _ in $(seq 1 360); do [ -f "$H/jobs/READY" ] && break; sleep 5; done
|
|
sleep 20
|
|
{ snap after; echo "== holder3.out"; grep -a "holder3 ready\|sealed memfd" "$H/holder3.out"; } >>"$OUT/$LABEL.txt" 2>&1
|
|
note "holder window $LABEL: $FORM holder started; $(grep -a 'holder3 ready' "$H/holder3.out" | tail -1); Shmem $(awk '/^Shmem:/{printf "%.1f GiB", $2/1048576}' /proc/meminfo), MemAvailable $(awk '/^MemAvailable:/{printf "%.1f GiB", $2/1048576}' /proc/meminfo); record $OUT/$LABEL.txt"
|