Files
leleka/scripts/laptop/monitor.sh
T
Pavlo RatushnyiandClaude Opus 5.5 bbba0f231d bench(laptop): paired Original/port harness on fixed pre-tokenized prompts
* tokenizer example `chat_tokens`: one user turn per line, thinking off, to comma-separated IDs, so both
  engines get exactly the same token IDs (benchmarks/laptop/prompts.txt: 3 prompts, 78-88 tokens).
* leleka-runtime ignored test `original_serve_laptop_bench`: opens the Original serve stack with the
  low-RAM sources (mapped experts, read-only KAR file; resident/memfd still selectable), serves every prompt
  REPEAT times greedily and prints TTFT, prompt/decode phase times, prefill/decode tok/s, memory and the
  output IDs of the first pass.
* scripts/laptop: original_bench.sh drives the unmodified `strata generate --serve` (setup.py's IQ3_S
  arguments, conversation cache off, one GEN at a time, TTFT to the first T line); port_bench.sh runs the
  test; monitor.sh samples process RSS/anon/file/shmem/locked/pinned and GPU VRAM once a second.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 11:27:46 +02:00

19 lines
1.2 KiB
Bash

#!/usr/bin/env bash
# Sample one process's memory and the GPU's VRAM once a second until it exits (laptop profile benches).
# monitor.sh PID OUT.tsv
# Columns: unix time, VRAM used MiB (nvidia-smi, whole GPU), VmRSS, RssAnon, RssFile, RssShmem, VmLck, VmPin (MiB),
# MemAvailable (MiB, whole VM). Prints the peaks when the process is gone.
set -u
pid="$1"; out="$2"
printf 't\tvram\trss\tanon\tfile\tshmem\tlck\tpin\tavail\n' > "$out"
field() { awk -v k="$1:" '$1==k {printf "%d", $2/1024}' "/proc/$pid/status" 2>/dev/null; }
while kill -0 "$pid" 2>/dev/null; do
vram=$(nvidia-smi --query-gpu=memory.used --format=csv,noheader,nounits 2>/dev/null | head -1)
avail=$(awk '$1=="MemAvailable:" {printf "%d", $2/1024}' /proc/meminfo)
printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$(date +%s)" "${vram:-0}" "$(field VmRSS)" "$(field RssAnon)" \
"$(field RssFile)" "$(field RssShmem)" "$(field VmLck)" "$(field VmPin)" "$avail" >> "$out"
sleep 1
done
awk -F'\t' 'NR>1 {for (i=2;i<=9;i++) if ($i+0>m[i]) m[i]=$i+0; if (min==""||$9+0<min) min=$9+0}
END {printf "peak MiB: vram=%d rss=%d anon=%d file=%d shmem=%d lck=%d pin=%d; min MemAvailable=%d\n", m[2],m[3],m[4],m[5],m[6],m[7],m[8],min}' "$out"