PSI/cgroup-aware governor with efficient/balanced/aggressive profiles, background pacing and thread priorities; timing histograms and optional Tracy zones; a capped Docker KPI harness with report/compare tooling. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
76 lines
2.3 KiB
Bash
Executable file
76 lines
2.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Runs inside the KPI container (see scripts/perf_kpi.sh). Phases are logged to
|
|
# /kpi/phases.log as "<epoch> <phase>"; daemon status is sampled every 2 s into
|
|
# /kpi/status.jsonl.
|
|
set -uo pipefail
|
|
|
|
BIN=/src/builddir/src/strawberry
|
|
CONF=/kpi/strawberry.conf
|
|
STARTUP_S=${STARTUP_S:-30}
|
|
IDLE_S=${IDLE_S:-60}
|
|
STORM_S=${STORM_S:-30}
|
|
LARGE_S=${LARGE_S:-20}
|
|
RELOAD_S=${RELOAD_S:-20}
|
|
|
|
phase() { echo "$(date +%s.%N) $1" >> /kpi/phases.log; echo "== $1"; }
|
|
|
|
"$BIN" "$CONF" > /kpi/daemon.log 2>&1 &
|
|
DAEMON=$!
|
|
phase start
|
|
for _ in $(seq 120); do
|
|
"$BIN" --status --json "$CONF" > /dev/null 2>&1 && break
|
|
sleep 0.5
|
|
done
|
|
|
|
( while kill -0 "$DAEMON" 2>/dev/null; do
|
|
"$BIN" --status --json "$CONF" 2>/dev/null | sed "s/^/$(date +%s.%N) /" >> /kpi/status.jsonl
|
|
sleep 2
|
|
done ) &
|
|
SAMPLER=$!
|
|
|
|
phase startup
|
|
sleep "$STARTUP_S"
|
|
|
|
phase idle
|
|
sleep "$IDLE_S"
|
|
|
|
# Exec storm under CPU pressure for STORM_S seconds: two busy loops compete
|
|
# with 8 parallel streams of short execs (new and repeated binaries).
|
|
phase storm
|
|
timeout "$STORM_S" sha256sum /dev/zero & HOG1=$!
|
|
timeout "$STORM_S" sha256sum /dev/zero & HOG2=$!
|
|
STORM_PIDS=""
|
|
for n in $(seq 8); do
|
|
( end=$(( $(date +%s) + STORM_S )); i=0
|
|
while [ "$(date +%s)" -lt "$end" ]; do
|
|
/bin/true; /usr/bin/env true; i=$((i + 2))
|
|
done; echo "$i" > /tmp/storm.$n ) &
|
|
STORM_PIDS="$STORM_PIDS $!"
|
|
done
|
|
# Only the storm workers: a bare `wait` would also wait for the status sampler.
|
|
wait $STORM_PIDS "$HOG1" "$HOG2" 2>/dev/null
|
|
echo "storm_execs $(cat /tmp/storm.* | awk '{s+=$1} END {print s}')" >> /kpi/phases.log
|
|
|
|
# Large executables for LARGE_S seconds: four distinct 96 MiB binaries
|
|
# (true + padding), each new to the scanner, then repeated.
|
|
phase large
|
|
for n in 1 2 3 4; do
|
|
cp /bin/true /tmp/big_true_$n
|
|
head -c $((96 * 1024 * 1024)) /dev/urandom >> /tmp/big_true_$n
|
|
chmod +x /tmp/big_true_$n
|
|
done
|
|
end=$(( $(date +%s) + LARGE_S )); i=0
|
|
while [ "$(date +%s)" -lt "$end" ]; do
|
|
for n in 1 2 3 4; do /tmp/big_true_$n; done; i=$((i + 4))
|
|
done
|
|
echo "large_execs $i" >> /kpi/phases.log
|
|
|
|
phase reload
|
|
"$BIN" --reload-rules "$CONF" > /dev/null 2>&1
|
|
sleep "$RELOAD_S"
|
|
|
|
phase end
|
|
"$BIN" --status --json "$CONF" > /kpi/final_status.json 2>/dev/null
|
|
kill "$SAMPLER" 2>/dev/null
|
|
kill -TERM "$DAEMON"; wait "$DAEMON" 2>/dev/null
|
|
echo done
|