A/B sampler: pgrep -x on the 15-character comm of leleka-inference; summary keys on MemAvailable

This commit is contained in:
Pavlo Ratushnyi
2026-11-03 00:19:07 +01:00
parent 24f1ba4a25
commit 766f844870
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ report_pid() { # pid name cmd
done
}
seen=" "
for name in leleka-inference leleka leleka-daemon strata-next leleka-cli python3; do
for name in leleka-inferenc leleka leleka-daemon strata-next leleka-cli python3; do # comm is truncated to 15 chars: pgrep -x leleka-inference never matches
for pid in $(pgrep -u "$USER" -x "$name" 2>/dev/null); do
cmd=$(cmdline "$pid")
if [ "$name" = python3 ]; then case "$cmd" in *kar_holder*|*single-copy-holder*) ;; *) continue ;; esac; fi
+2 -2
View File
@@ -86,7 +86,7 @@ sampler() { # $1 output prefix: memsample (5 s) and a full inventory every 60 s
local i=0
while sleep 5; do
i=$((i + 1))
pid=$(pgrep -u "$USER" -x leleka-inference | head -1)
pid=$(pgrep -u "$USER" -x leleka-inferenc | head -1)
eng=""; [ -n "$pid" ] && eng=$(awk '/^(RssAnon|RssShmem|RssFile|VmLck):/{printf "%s%s ", $1, $2}' /proc/$pid/status 2>/dev/null)
echo "$(date -u +%T) $(grep -E "SwapFree|MemAvailable|^Cached|^Shmem:|^AnonPages|^Mlocked|Dirty" /proc/meminfo | tr -s " " | tr "\n" " ") $(head -1 /proc/pressure/io) $(head -1 /proc/pressure/memory) $(awk '/pswpin|pswpout|pgmajfault/{printf "%s=%s ", $1, $2}' /proc/vmstat) ENGINE ${eng:-none}" >> "$1.memsample.txt"
if [ $((i % 12)) = 0 ]; then bash "$INV" "t+$((i*5))s" "${MODEL_FILES[@]}" >> "$1.inventory.txt" 2>&1; fi
@@ -333,7 +333,7 @@ print("== RAM: system Shmem / MemAvailable at the last sample with an engine, an
for k in runs:
f = os.path.join(root, k, "run.memsample.txt")
if os.path.exists(f):
ls = [l for l in open(f, errors="replace") if "RssAnon" in l]
ls = [l for l in open(f, errors="replace") if "MemAvailable" in l]
if ls:
l = ls[-1]; g = lambda n: next((int(x) for x in re.findall(n + r":?\s*(\d+)", l)), 0) / 1048576
sw = [int(x) for ln in (ls[0], l) for x in re.findall(r"pswp(?:in|out)=(\d+)", ln)]