#!/bin/bash # tools/run/host/train.sh : the PGO training run of the # `makepad` JIT binary (build.sh gen / build.sh pgo). Representative JIT work, each from its own fresh run home: # Stage cold (present, idle, the first-visit tab burst), Stage warm (same home: warm start + burst), # Calculator cold, Sandbox boot into the race game, three rwbench workloads (lowering + O3 compile), # `makepad check` of makepad-widgets and makepad-platform (front end, typeck, borrowck), `makepad test relax-lex` (test harness). # Every app is stopped with SIGTERM (makepad run's quit path: the process exits normally, so the profile # runtime writes its .profraw; a forced exit would lose that run's counts). Runs need the source tree with # apps/commercial (Stage, Sandbox); a missing app is skipped with a note. # Linux: runs on the current Wayland/X display, or starts a headless weston for the training (stopped by PID). # macOS: hidden windows (MAKEPAD_HIDE_WINDOWS=1). set -uo pipefail here=$(cd "$(dirname "$0")" && pwd) root=$(cd "$here/../../.." && pwd) BIN=$(cd "$(dirname "$1")" && pwd)/$(basename "$1") RAW=$2 W=$3 mkdir -p "$RAW" "$W" RAW=$(cd "$RAW" && pwd) W=$(cd "$W" && pwd) export LLVM_PROFILE_FILE=$RAW/makepad_%m_%p.profraw export MAKEPAD_HIDE_WINDOWS=1 SANDBOX_MUTE=1 MUSIC_MUTE=1 MAKEPAD_GGML_NO_CUDA=1 # the tree's own std (the binary may live outside the tree) export MAKEPAD_RUN_STD=$root/libs/relax/compiler/std weston_pid="" if [ "$(uname)" = Linux ] && [ -z "${WAYLAND_DISPLAY:-}" ] && [ -z "${DISPLAY:-}" ]; then export XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR:-/run/user/$(id -u)} WAYLAND_DISPLAY=wayland-hosttrain-$$ setsid weston --backend=headless --renderer=gl --socket=$WAYLAND_DISPLAY --width=1600 --height=900 \ --idle-time=0 > "$W/weston.log" 2>&1 & weston_pid=$! sleep 2 fi cleanup() { [ -n "$weston_pid" ] && kill "$weston_pid" 2>/dev/null; } trap cleanup EXIT home() { rm -rf "$W/home-$1"; mkdir -p "$W/home-$1/tmp"; } # app