prefill: pf_memstat.sh also samples PSI cpu and the engine's run-queue wait
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
5e0b2e5e38
commit
d3481981bc
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user