carlos / todomvc-bakeoff Public
fix: wake sampler leaves each app alone 16 minutes after a sample
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+12
−4
scripts/measure-wake.sh+12 −4
diff --git a/scripts/measure-wake.sh b/scripts/measure-wake.sh| index 5f5594f..df7b146 100755 |
| --- a/scripts/measure-wake.sh |
| +++ b/scripts/measure-wake.sh |
| @@ -1,22 +1,30 @@ |
| #!/usr/bin/env bash |
| # Collects wake-from-sleep samples: every 2 minutes, any app whose instance |
| -# the platform reports asleep gets one first request timed. Runs until |
| -# every app has <samples> samples (default 3). Nothing else may touch the |
| -# apps meanwhile, or they never fall asleep. |
| +# the platform's own log says is asleep (latest event "stopping"/"exited") |
| +# gets one first request timed. After a sample an app is left alone for at |
| +# least 16 minutes (the idle window is 15), because the log is flushed |
| +# periodically and can lag. Runs until every app has <samples> samples. |
| +# Nothing else may touch the apps meanwhile. |
| # scripts/measure-wake.sh [samples] [slug...] |
| set -uo pipefail |
| cd "$(dirname "$0")/.." |
| want=${1:-3}; shift || true |
| slugs=("$@") |
| [ ${#slugs[@]} -gt 0 ] || slugs=(go go-rastrillo rust zig ocaml haskell swift nim spinel) |
| +declare -A last |
| have() { python3 -c "import json,sys; print(len(json.load(open('results/$1.json')).get('Wake') or []))"; } |
| while :; do |
| left=0 |
| + now=$(date +%s) |
| for s in "${slugs[@]}"; do |
| n=$(have "$s") |
| [ "$n" -ge "$want" ] && continue |
| left=1 |
| - bakeoff wake --slug "$s" && echo "$(date +%H:%M) $s sample $((n+1))" |
| + [ $(( now - ${last[$s]:-0} )) -lt 960 ] && continue |
| + if bakeoff wake --slug "$s"; then |
| + last[$s]=$(date +%s) |
| + echo "$(date +%H:%M) $s sample $((n+1))" |
| + fi |
| done |
| [ $left = 0 ] && break |
| sleep 120 |