From d3481981bc4fadc4e7b4a24f46f28d4cfc0d588c Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Mon, 9 Nov 2026 11:54:04 +0100 Subject: [PATCH] prefill: pf_memstat.sh also samples PSI cpu and the engine's run-queue wait Co-Authored-By: Claude Sonnet 5.5 --- scripts/e2e/codex/prefill/pf_memstat.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/e2e/codex/prefill/pf_memstat.sh b/scripts/e2e/codex/prefill/pf_memstat.sh index e5815036..8d4930f3 100644 --- a/scripts/e2e/codex/prefill/pf_memstat.sh +++ b/scripts/e2e/codex/prefill/pf_memstat.sh @@ -1,7 +1,8 @@ #!/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 +# compaction stalls (system wide), then the engine process: pid, major faults, minor faults, then PSI cpu some total (us) and the summed run-queue wait +# (run_delay, ns) of all threads of the engine process # 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} @@ -12,7 +13,9 @@ while :; do 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" + cpu=$(awk '/^some/{split($5,s,"=")} END{print s[2]}' /proc/pressure/cpu 2>/dev/null) + rd=0; [ -n "$pid" ] && rd=$(cat /proc/"$pid"/task/*/schedstat 2>/dev/null | awk '{d+=$2} END{print d+0}') + echo "$(date +%s%3N),$psi,$sys,$proc,$cpu,$rd" >>"$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)