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/est4_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 / est4_collect.sh` 77 lines ยท 3551 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 v4 (docs/estimation/protocols/est-v4.md) data collection under the 18 # declared est_load schedule. Same collector as v3 (est3c_collect.sh); only the 19 # folder tag, the flag owner text and the est_load process check differ. 20 # tools/estimation/est4_collect.sh 21 # Writes /-est4--silicon/ with machine-state.ndjson (1 Hz), 22 # machine-state-marks.txt, schedule.txt, machine-state-start.txt, SHA256SUMS. 23 # Coordination: refuses to start while ~/workspace/.spark-quiet exists or any 24 # est_load process runs; holds the flag (text "lane15 est v4 load period") for 25 # its own run and removes it afterwards. Prints no thermal statistic. 26 set -u 27 role=${1:?fit, heldout or smoke} 28 secs=${2:?seconds} 29 seed=${3:?seed} 30 root=${4:?raw root} 31 load=${5:?est_load binary} 32 quiet=$HOME/workspace/.spark-quiet 33 if pgrep -x est_load > /dev/null 2>&1; then 34 echo "est4_collect: an est_load process is running; refusing" >&2 35 exit 3 36 fi 37 # Take the flag atomically (noclobber): refuse if another run owns the machine. 38 if ! ( set -C; printf 'owner: lane15 est v4 load period (%s)\nstarted: %s\nexpected end: %s\nplease: no builds or tests until this file is gone\n' \ 39 "$role" "$(date -u +%FT%TZ)" "$(date -u -d "+$secs seconds" +%FT%TZ)" > "$quiet" ) 2> /dev/null; then 40 echo "est4_collect: $quiet exists; another run owns the machine" >&2 41 exit 3 42 fi 43 lpid= 44 cleanup() { 45 [ -n "$lpid" ] && kill "$lpid" 2> /dev/null 46 rm -f "$quiet" 47 } 48 trap cleanup EXIT 49 trap 'exit 4' HUP INT TERM 50 mkdir -p "$root" || exit 5 51 d=$root/$(date -u +%Y%m%dT%H%M%SZ)-est4-$role-silicon 52 # Plain mkdir: refuses an existing folder, so a prior collection is never truncated. 53 mkdir "$d" || { echo "est4_collect: $d already exists; refusing" >&2; exit 5; } 54 date -u +%FT%TZ > "$d/machine-state-start.txt" 55 : > "$d/machine-state-marks.txt" 56 "$load" "$seed" "$secs" "$d/machine-state-marks.txt" > "$d/schedule.txt" & 57 lpid=$! 58 end=$(( $(date +%s) + secs )) 59 while [ "$(date +%s)" -lt "$end" ]; do 60 t=$(date +%s.%N) 61 th=$(cat /sys/class/thermal/thermal_zone*/temp | tr '\n' ' ') 62 la=$(cut -d' ' -f1-3 /proc/loadavg) 63 cpu=$(head -1 /proc/stat | cut -d' ' -f3-10) 64 printf '{"t":%s,"thermal_mc":"%s","loadavg":"%s","cpu":"%s"}\n' "$t" "$th" "$la" "$cpu" >> "$d/machine-state.ndjson" 65 if ! kill -0 "$lpid" 2> /dev/null && [ "$(( end - $(date +%s) ))" -gt 5 ]; then 66 echo "est4_collect: est_load exited early; collection is INVALID" >&2 67 lpid=; echo INVALID_EARLY_LOAD_EXIT > "$d/INVALID"; exit 6 68 fi 69 sleep 1 70 done 71 wait "$lpid"; rc=$?; lpid= 72 if [ "$rc" -ne 0 ]; then 73 echo "est4_collect: est_load exit status $rc; collection is INVALID" >&2 74 echo "INVALID_LOAD_EXIT $rc" > "$d/INVALID"; exit 6 75 fi 76 (cd "$d" && sha256sum machine-state.ndjson machine-state-marks.txt machine-state-start.txt schedule.txt > SHA256SUMS) 77 echo "$d"