Files
serverAppConfigs/old/scripts/prune-rpc-cache.sh
T

37 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Bound the ggml-rpc worker tensor cache.
#
# The worker (frank-pp-worker on Dankserver) keys cache entries per
# session, so each model load writes a fresh full copy (~15 GB). Left
# unbounded, the directory filled the root disk to 100% on 2026-08-17;
# failed cache writes left 0-byte entries, and a later reload served
# corrupt weights -> degenerate model output (see the cache incident in
# docs/Pipeline Parallelism/Qwen3.8 PP Deployment.md).
#
# This script prunes the cache to a byte cap, oldest files first. Cache
# entries are derived data: safe to delete. Run from cron on Dankserver.
set -euo pipefail
CACHE_DIR=/home/dank/.cache/llama.cpp/rpc
MAX_BYTES=$((40 * 1024 * 1024 * 1024)) # 40 GiB
if [[ ! -d "$CACHE_DIR" ]]; then
exit 0
fi
total=$(du -sb "$CACHE_DIR" | cut -f1)
if (( total <= MAX_BYTES )); then
exit 0
fi
while (( total > MAX_BYTES )); do
oldest=$(ls -1t "$CACHE_DIR" | tail -1)
if [[ -z "$oldest" ]]; then
break
fi
rm -f -- "$CACHE_DIR/$oldest"
total=$(du -sb "$CACHE_DIR" | cut -f1)
done
echo "prune-rpc-cache: pruned to $(du -sh "$CACHE_DIR" | cut -f1)"