prefill: pf_memstat.sh (host and engine-process memory counters per session), pf_van_window.sh (vanilla VANL window with the same counters); pf_codex_job.sh uses the sampler
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
8e66a516de
commit
0a294bc73c
@@ -56,9 +56,8 @@ export LELEKA_SPEC_STATS=1
|
||||
STK=$RUN/$VAR/stack-r$BLK; mkdir -p "$STK"
|
||||
{ date -u +%FT%TZ; uname -r; nvidia-smi --query-gpu=name,driver_version,power.limit --format=csv,noheader; free -g | sed -n 2p; cat "$PL/pkg/COMMIT.txt"; env | grep -E '^(LELEKA_|STRATA_)' | grep -v KEY | sort; } | tee "$STK/host.txt"
|
||||
nvidia-smi --query-gpu=timestamp,temperature.gpu,clocks.sm,clocks.mem,power.draw,utilization.gpu --format=csv -l 10 >"$STK/mon.csv" 2>/dev/null & MON_PID=$!
|
||||
# Host memory counters every 0.25 s (epoch ms, PSI memory some/full total us, direct-reclaim stalls, major faults, direct scans, compaction stalls):
|
||||
# a request stall of the host-only spans (`input`, `other`) is matched against them by the request timestamps.
|
||||
( while :; do v=$(awk '/^allocstall_/{a+=$2} /^pgmajfault /{m=$2} /^pgscan_direct /{d=$2} /^compact_stall /{c=$2} END{print a","m","d","c}' /proc/vmstat); p=$(awk '/^some/{split($5,s,"=")} /^full/{split($5,f,"=")} END{print s[2]","f[2]}' /proc/pressure/memory 2>/dev/null); echo "$(date +%s%3N),$p,$v"; sleep 0.25; done ) >"$STK/memstat.csv" 2>/dev/null & PSI_PID=$!
|
||||
# Host memory counters (pf_memstat.sh: memstat.csv every 0.25 s, memstat.mem.csv every 15 s): a stall of the host-only spans (`input`, `other`) is matched against them by the request timestamps.
|
||||
bash "$PL/tools/pf_memstat.sh" "$STK/memstat" & PSI_PID=$!
|
||||
# The engine log rotates at 16 MiB and the rotated files are overwritten by the next run: keep the profile lines of the whole session (epoch ms first).
|
||||
( tail -n 0 -F "$ST/logs/engine.log" 2>/dev/null | grep --line-buffered -a -E 'PREFILL-PROFILE|DBG profile request|"ev":"request"' | while IFS= read -r l; do echo "$(date +%s%3N) $l"; done ) >"$STK/prof.log" 2>/dev/null & TAIL_PID=$!
|
||||
COMMON="--assets $AS --state-dir $ST --prefix $PFX --bin-src $BIN --cublas-dir $CUBLAS --trust-archive --kar-fd $FD"
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
# Prefill fixed-latency program: host memory sampler, one per session (test tooling, never in serving). pf_memstat.sh OUT_PREFIX
|
||||
# OUT_PREFIX.csv every 0.25 s: epoch_ms, PSI memory some/full total (us), direct-reclaim stalls (sum of allocstall_*), major faults, direct scans,
|
||||
# compaction stalls (system wide), then the engine process: pid, major faults, minor faults
|
||||
# OUT_PREFIX.mem.csv every 15 s: epoch_ms, MemAvailable, MemFree, Cached, Shmem, Mapped, Active(file), Inactive(file) (kB), engine RssAnon, RssFile, RssShmem (kB)
|
||||
# The engine process is the leleka-inference (ours) or the vanilla Strata engine binary, found by name; 0 when none runs.
|
||||
OUT=${1:?OUT_PREFIX}
|
||||
engine_pid() { pgrep -u "$USER" -f 'leleka-inference|components/engine/[^ ]*/strata' 2>/dev/null | head -1; }
|
||||
pid=; n=0
|
||||
while :; do
|
||||
{ [ -n "$pid" ] && [ -r "/proc/$pid/stat" ]; } || pid=$(engine_pid)
|
||||
sys=$(awk '/^allocstall_/{a+=$2} /^pgmajfault /{m=$2} /^pgscan_direct /{d=$2} /^compact_stall /{c=$2} END{print a","m","d","c}' /proc/vmstat)
|
||||
psi=$(awk '/^some/{split($5,s,"=")} /^full/{split($5,f,"=")} END{print s[2]","f[2]}' /proc/pressure/memory 2>/dev/null)
|
||||
proc=0,0,0; [ -n "$pid" ] && proc=$(awk -v p="$pid" '{sub(/^[^)]*\) /,""); split($0,a," "); print p","a[10]","a[8]}' "/proc/$pid/stat" 2>/dev/null || echo "$pid,0,0")
|
||||
echo "$(date +%s%3N),$psi,$sys,$proc" >>"$OUT.csv"
|
||||
if [ $((n % 60)) = 0 ]; then
|
||||
mi=$(awk '{v[$1]=$2} END{print v["MemAvailable:"]","v["MemFree:"]","v["Cached:"]","v["Shmem:"]","v["Mapped:"]","v["Active(file):"]","v["Inactive(file):"]}' /proc/meminfo)
|
||||
rs=0,0,0; [ -n "$pid" ] && rs=$(awk '/^RssAnon:/{a=$2} /^RssFile:/{f=$2} /^RssShmem:/{s=$2} END{print a","f","s}' "/proc/$pid/status" 2>/dev/null)
|
||||
echo "$(date +%s%3N),$mi,$rs" >>"$OUT.mem.csv"
|
||||
fi
|
||||
n=$((n + 1)); sleep 0.25
|
||||
done
|
||||
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
# Prefill fixed-latency program: a copy of codex-compare/tools/cmp_window.sh for the vanilla arm (variant VANL) that records the host memory counters of the session
|
||||
# (pf_memstat.sh: memstat.csv / memstat.mem.csv next to the stack directory) and writes its results under the prefill-latency task directory. pf_van_window.sh LABEL
|
||||
# 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.
|
||||
# 1. waits until the lab holder has ended and its memfd is gone; 2. runs codex-compare/tools/cmp_codex_job.sh (unchanged, CMP_* from the stub); 3. ALWAYS restarts the lab holder.
|
||||
set -u
|
||||
LABEL=${1:-window}
|
||||
C=/data/leleka-e2e/codex-compare
|
||||
PL=/data/leleka-e2e/prefill-latency
|
||||
H=$HOME/work/gpu-runs/holder2
|
||||
NOTES=/data/leleka-e2e/decode/notes.md
|
||||
note() { echo "[$(date -u +%FT%TZ)] [DEV prefill-latency] $*" >> "$NOTES"; }
|
||||
SAMPLER=
|
||||
restart_holder() {
|
||||
[ -n "$SAMPLER" ] && kill "$SAMPLER" 2>/dev/null
|
||||
if pgrep -u "$USER" -f 'kar_holder2?\.py|single-copy-holder\.py' >/dev/null; then echo "a holder is already running"; return; fi
|
||||
rmdir "$HOME/work/gpu-runs/MODEL.lock" 2>/dev/null
|
||||
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 && setsid nohup bash /data/leleka-e2e/single-copy/tools/single-copy-holder.sh > "$H/holder3.out" 2>&1 < /dev/null & )
|
||||
note "window $LABEL over: holder restarted with single-copy-holder.sh (holder3.out); queue open again"
|
||||
}
|
||||
trap restart_holder EXIT
|
||||
note "window $LABEL: waiting for the holder to end (jobs/STOP is set), then cmp_codex_job.sh: arm=${CMP_ARM:-?} reps=[${CMP_REPS:-}] tasks=[${CMP_TASKS:-}] run=${CMP_RUN:-}"
|
||||
for _ in $(seq 1 1440); do
|
||||
if ! pgrep -u "$USER" -f 'kar_holder2?\.py|single-copy-holder\.py' >/dev/null && [ ! -d "$HOME/work/gpu-runs/MODEL.lock" ]; then break; fi
|
||||
sleep 5
|
||||
done
|
||||
if pgrep -u "$USER" -f 'kar_holder2?\.py|single-copy-holder\.py' >/dev/null; then note "window $LABEL: the holder did not end in 2 h, giving up (holder left as it is)"; trap - EXIT; exit 3; fi
|
||||
sleep 5
|
||||
note "window $LABEL: holder gone, MemAvailable $(awk '/^MemAvailable:/{printf "%d GiB", $2/1048576}' /proc/meminfo); starting"
|
||||
OUTD=${CMP_RUN:-$PL/runs/van}/VANL; mkdir -p "$OUTD"
|
||||
bash "$PL/tools/pf_memstat.sh" "$OUTD/memstat-r$(echo "${CMP_REPS:-1}" | tr ' ' '+')" & SAMPLER=$!
|
||||
bash "$C/tools/cmp_codex_job.sh" > "$PL/window-$LABEL.out" 2>&1
|
||||
note "window $LABEL: cmp_codex_job.sh ended rc=$?; log $PL/window-$LABEL.out"
|
||||
Reference in New Issue
Block a user