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
omega-mv / tools / estimation / est3c_collect.sh
| 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 | # EST-3c (protocol v3, docs/estimation/EST3C_PROTOCOL_V3.md) data collection |
| 18 | # under a declared CPU load schedule. |
| 19 | # tools/estimation/est3c_collect.sh <fit|heldout|smoke> <seconds> <seed> <raw-root> <est_load-binary> |
| 20 | # Writes <raw-root>/<UTC>-est3c-<role>-silicon/ with |
| 21 | # machine-state.ndjson 1 Hz lines {"t":<s.ns>,"thermal_mc":"<z0> <z1> ...", |
| 22 | # "loadavg":"<1m 5m 15m>","cpu":"<user nice system idle iowait irq softirq steal>"} |
| 23 | # (same thermal shape as R15 / EST-3b; extra keys are ignored by est_replay) |
| 24 | # machine-state-marks.txt load trials written by est_load (R15 marks shape) |
| 25 | # schedule.txt the schedule est_load derived from <seed>, printed before it started |
| 26 | # machine-state-start.txt, SHA256SUMS |
| 27 | # Coordination: refuses to start while ~/workspace/.spark-quiet exists (another |
| 28 | # timed run owns the machine); creates it for the duration of its own run and |
| 29 | # removes it afterwards. No root, no perf, no /dev/null, no Python. |
| 30 | set -u |
| 31 | role=${1:?fit, heldout or smoke} |
| 32 | secs=${2:?seconds} |
| 33 | seed=${3:?seed} |
| 34 | root=${4:?raw root} |
| 35 | load=${5:?est_load binary} |
| 36 | quiet=$HOME/workspace/.spark-quiet |
| 37 | if [ -e "$quiet" ]; then |
| 38 | echo "est3c_collect: $quiet exists; another timed run owns the machine" >&2 |
| 39 | exit 3 |
| 40 | fi |
| 41 | printf 'owner: lane4 ESTIMATION-2 est3c %s collection\nstarted: %s\nexpected end: %s\nplease: no builds or tests until this file is gone\n' \ |
| 42 | "$role" "$(date -u +%FT%TZ)" "$(date -u -d "+$secs seconds" +%FT%TZ)" > "$quiet" |
| 43 | d=$root/$(date -u +%Y%m%dT%H%M%SZ)-est3c-$role-silicon |
| 44 | mkdir -p "$d" |
| 45 | date -u +%FT%TZ > "$d/machine-state-start.txt" |
| 46 | : > "$d/machine-state-marks.txt" |
| 47 | "$load" "$seed" "$secs" "$d/machine-state-marks.txt" > "$d/schedule.txt" & |
| 48 | lpid=$! |
| 49 | end=$(( $(date +%s) + secs )) |
| 50 | while [ "$(date +%s)" -lt "$end" ]; do |
| 51 | t=$(date +%s.%N) |
| 52 | th=$(cat /sys/class/thermal/thermal_zone*/temp | tr '\n' ' ') |
| 53 | la=$(cut -d' ' -f1-3 /proc/loadavg) |
| 54 | cpu=$(head -1 /proc/stat | cut -d' ' -f3-10) |
| 55 | printf '{"t":%s,"thermal_mc":"%s","loadavg":"%s","cpu":"%s"}\n' "$t" "$th" "$la" "$cpu" >> "$d/machine-state.ndjson" |
| 56 | sleep 1 |
| 57 | done |
| 58 | wait "$lpid" |
| 59 | (cd "$d" && sha256sum machine-state.ndjson machine-state-marks.txt machine-state-start.txt schedule.txt > SHA256SUMS) |
| 60 | rm -f "$quiet" |
| 61 | echo "$d" |