Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/tools/estimation/est5_collect.sh # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / tools / estimation / est5_collect.sh` 102 lines ยท 4473 bytes Raw Blame History 1 #!/bin/sh 2 # SPDX-License-Identifier: Apache-2.0 3 # Copyright 2026 Drake Stapleton (AIEN / aien-dev) 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 # ESTIMATION v5 (docs/estimation/protocols/est-v5.md) data collection under the declared 18 # est_load schedule. The v4 collector (est4_collect.sh) with an ENFORCED WINDOW: it runs only 19 # while the caller holds the machine-wide quiet flag for this gate (the flag is enforced by 20 # the quiet-guard hook), it never creates or removes the flag, it refuses to start when a 21 # foreign build/test/gate process is already running, and it records a process monitor 22 # (process-monitor.log, one sample every 2 s) whose verdict est5_window_check.sh gives. 23 # tools/estimation/est5_collect.sh 24 # Writes /-est5--silicon/ with machine-state.ndjson (1 Hz), 25 # machine-state-marks.txt, schedule.txt, machine-state-start.txt, process-monitor.log, 26 # WINDOW verdict and SHA256SUMS. Prints no thermal statistic. 27 set -u 28 role=${1:?fit, heldout or smoke} 29 secs=${2:?seconds} 30 seed=${3:?seed} 31 root=${4:?raw root} 32 load=${5:?est_load binary} 33 here=$(cd "$(dirname "$0")" && pwd) 34 quiet=$HOME/workspace/.spark-quiet 35 if ! grep -q '^gate est-v5$' "$quiet" 2> /dev/null; then 36 echo "est5_collect: $quiet missing or not held for gate est-v5; the window must be held first" >&2 37 exit 3 38 fi 39 if pgrep -x est_load > /dev/null 2>&1; then 40 echo "est5_collect: an est_load process is running; refusing" >&2 41 exit 3 42 fi 43 pre=$(sh "$here/est5_window_scan.sh" 0) 44 if [ -n "$pre" ]; then 45 echo "est5_collect: foreign build/test/gate process already running; refusing:" >&2 46 echo "$pre" | head -5 >&2 47 exit 3 48 fi 49 lpid= 50 mpid= 51 cleanup() { 52 [ -n "$lpid" ] && kill "$lpid" 2> /dev/null 53 [ -n "$mpid" ] && kill "$mpid" 2> /dev/null 54 } 55 trap cleanup EXIT 56 trap 'exit 4' HUP INT TERM 57 mkdir -p "$root" || exit 5 58 d=$root/$(date -u +%Y%m%dT%H%M%SZ)-est5-$role-silicon 59 # Plain mkdir: refuses an existing folder, so a prior collection is never truncated. 60 mkdir "$d" || { echo "est5_collect: $d already exists; refusing" >&2; exit 5; } 61 date -u +%FT%TZ > "$d/machine-state-start.txt" 62 : > "$d/machine-state-marks.txt" 63 : > "$d/process-monitor.log" 64 "$load" "$seed" "$secs" "$d/machine-state-marks.txt" > "$d/schedule.txt" & 65 lpid=$! 66 # process monitor: a sample line every 2 s, FOREIGN lines for builds/tests/gates, and 67 # informational HIGHCPU lines (any process above 25 % CPU other than the load generator). 68 ( 69 while :; do 70 ts=$(date -u +%FT%TZ) 71 echo "$ts S $(ps -e --no-headers | wc -l)" 72 sh "$here/est5_window_scan.sh" "$lpid" | sed "s/^/$ts /" 73 ps -eo pid=,pcpu=,comm= | awk -v own="$lpid" -v ts="$ts" '$1 != own && $2 > 25 { print ts, "HIGHCPU", $1, $2, $3 }' 74 sleep 2 75 done 76 ) >> "$d/process-monitor.log" 2> /dev/null & 77 mpid=$! 78 end=$(( $(date +%s) + secs )) 79 while [ "$(date +%s)" -lt "$end" ]; do 80 t=$(date +%s.%N) 81 th=$(cat /sys/class/thermal/thermal_zone*/temp | tr '\n' ' ') 82 la=$(cut -d' ' -f1-3 /proc/loadavg) 83 cpu=$(head -1 /proc/stat | cut -d' ' -f3-10) 84 printf '{"t":%s,"thermal_mc":"%s","loadavg":"%s","cpu":"%s"}\n' "$t" "$th" "$la" "$cpu" >> "$d/machine-state.ndjson" 85 if ! kill -0 "$lpid" 2> /dev/null && [ "$(( end - $(date +%s) ))" -gt 5 ]; then 86 echo "est5_collect: est_load exited early; collection is INVALID" >&2 87 lpid=; echo INVALID_EARLY_LOAD_EXIT > "$d/INVALID"; exit 6 88 fi 89 sleep 1 90 done 91 wait "$lpid"; rc=$?; lpid= 92 kill "$mpid" 2> /dev/null; mpid= 93 if [ "$rc" -ne 0 ]; then 94 echo "est5_collect: est_load exit status $rc; collection is INVALID" >&2 95 echo "INVALID_LOAD_EXIT $rc" > "$d/INVALID"; exit 6 96 fi 97 wrc=0 98 sh "$here/est5_window_check.sh" "$d" "$secs" > "$d/WINDOW" || wrc=$? 99 (cd "$d" && sha256sum machine-state.ndjson machine-state-marks.txt machine-state-start.txt schedule.txt process-monitor.log WINDOW > SHA256SUMS) 100 echo "$d" 101 cat "$d/WINDOW" >&2 102 [ "$wrc" -eq 0 ] || exit 7