Add timed craft queue and hangar

This commit is contained in:
Loïc Wisniewski 2026-08-12 22:47:46 +02:00
commit 82552464d2
14 changed files with 660 additions and 191 deletions

View file

@ -32,9 +32,36 @@ set -uo pipefail
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
# Leave headroom: Godot is memory-hungry and this is a phone, not a build
# server. Override with JOBS= if you know better.
JOBS="${JOBS:-6}"
# Worker count comes from FREE MEMORY, not core count. Each Godot instance is
# ~400MB and this phone shares its RAM with everything else running on it.
# Getting it wrong is bad in both directions:
# - too many and the kernel SIGKILLs the runner mid-suite (exit 137), which
# looks exactly like a hang
# - too many under swap pressure and every worker thrashes: the same suite
# measured 100-190s with memory free, and 888s while 9GB sat in swap
# One worker per ~900MB available, capped at 6, and forced to 1 once swap is
# more than half consumed - past that, parallelism costs more than it buys.
# Override with JOBS= when you know better.
_pick_jobs() {
local avail swap_total swap_free n
avail=$(awk '/MemAvailable/ {print int($2 / 1024)}' /proc/meminfo 2>/dev/null)
swap_total=$(awk '/SwapTotal/ {print $2}' /proc/meminfo 2>/dev/null)
swap_free=$(awk '/SwapFree/ {print $2}' /proc/meminfo 2>/dev/null)
if [[ -z "$avail" ]]; then
echo 2
return
fi
if [[ -n "$swap_total" ]] && (( swap_total > 0 )) \
&& (( (swap_total - swap_free) * 2 > swap_total )); then
echo 1
return
fi
n=$(( avail / 900 ))
(( n < 1 )) && n=1
(( n > 6 )) && n=6
echo "$n"
}
JOBS="${JOBS:-$(_pick_jobs)}"
VERBOSE="${VERBOSE:-0}"
IN_PLACE="${IN_PLACE:-0}"
WORK_DIR="${WORK_DIR:-$HOME/.cache/spaceship-tests}"