Battery: record host hardware in the run manifest, show it in the report

Collect CPU model, nominal/base frequency (with its source), physical
core/thread/socket counts, RAM and GPU name(s)/memory at run time
(Linux via /proc, /sys/.../cpufreq, nvidia-smi; a short best-effort on
macOS via sysctl), store it under manifest.json's new "hardware" key,
and render it as a line in the report header. Runs from before this
change have no such key; the report prints "not recorded" for them.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
leonarski_fandClaude Opus 5.5 committed 2026-10-03 20:08:00 +02:00
1 parent 2c97e654ed
commit 20dbf598be
3 files changed
+113 -3

No files matched your search

+3 -2
View File
@@ -334,7 +334,7 @@ read-only when the run completes.
| path | content |
|---|---|
| `bin/rugnux` | the exact binary that ran (sha256 in the manifest) |
| `manifest.json` | the label, arms, subset, options, binary version, build flags and source HEAD, runner git and dirty flag, host, pid, start and end, `complete` / `aborted`, `gpu_shared`, and every set with its resolved input, reference and tags |
| `manifest.json` | the label, arms, subset, options, binary version, build flags and source HEAD, runner git and dirty flag, host, hardware (CPU model and nominal frequency, physical/thread/socket counts, RAM, GPUs - empty on runs from before this was recorded), pid, start and end, `complete` / `aborted`, `gpu_shared`, and every set with its resolved input, reference and tags |
| `results.json` | one row per set (the schema is below) |
| `report.md`, `report.html` | the report (`report_PRIVATE.*` for a private run) |
| `work/<arm>/<set>/` | `run.log`, `p_report.txt`, `p.mtz`, `p.cif`, ... and `model_check/` |
@@ -403,7 +403,8 @@ was run `--unforced`), so its forced XDS-arm rows are left out the same way.
Every run writes the same report as Markdown and as a self-contained HTML page (inline CSS and
SVG, no external files):
- a header with the binary, build flags, host, subset, each arm's command and whether timing counts;
- a header with the binary, build flags, host, hardware (CPU, cores/threads/sockets, RAM, GPUs -
`not recorded` on an older run), subset, each arm's command and whether timing counts;
- a **summary per arm** (pass, of which accepted on an alternative reference / fail / unscored /
not run, pass rate, median resolution gain, ISa, R_meas, time) with a verdict bar chart, all
from rugnux's own run, and an **Accepted alternatives** section naming those rows and why;
+96 -1
View File
@@ -171,6 +171,100 @@ def gpu_others():
return len([x for x in out.split() if x.strip().isdigit()])
def gpu_hardware():
"""[{"name", "memory"}] from nvidia-smi, [] if there are none or it is absent."""
try:
out = subprocess.run(["nvidia-smi", "--query-gpu=name,memory.total", "--format=csv,noheader"],
capture_output=True, text=True, timeout=30).stdout
except (OSError, subprocess.TimeoutExpired):
return []
gpus = []
for line in out.splitlines():
parts = [p.strip() for p in line.split(",")]
if len(parts) == 2:
gpus.append({"name": parts[0], "memory": parts[1]})
return gpus
def linux_hardware():
blocks = []
try:
blocks = [b for b in open("/proc/cpuinfo").read().split("\n\n") if b.strip()]
except OSError:
pass
model = None
sockets, cores = set(), set()
for b in blocks:
m = re.search(r"model name\s*:\s*(.+)", b)
if m and model is None:
model = m.group(1).strip()
p, c = re.search(r"physical id\s*:\s*(\d+)", b), re.search(r"core id\s*:\s*(\d+)", b)
if p and c:
sockets.add(p.group(1))
cores.add((p.group(1), c.group(1)))
freq_ghz, freq_source = None, "unknown"
m = re.search(r"@\s*([\d.]+)\s*GHz", model or "")
if m:
freq_ghz, freq_source = float(m.group(1)), "model name"
else:
for name in ("base_frequency", "cpuinfo_max_freq"):
try:
freq_ghz = int(open(f"/sys/devices/system/cpu/cpu0/cpufreq/{name}").read()) / 1e6
freq_source = name
break
except (OSError, ValueError):
continue
mem_gib = None
try:
for line in open("/proc/meminfo"):
if line.startswith("MemTotal:"):
mem_gib = int(line.split()[1]) / 1024 / 1024 # kiB -> GiB
break
except OSError:
pass
return {"cpu_model": model or "unknown", "cpu_base_ghz": freq_ghz, "cpu_base_source": freq_source,
"sockets": len(sockets) or None, "physical_cores": len(cores) or None,
"threads": os.cpu_count(), "memory_gib": mem_gib, "gpus": gpu_hardware()}
def macos_hardware():
def sysctl(key):
r = subprocess.run(["sysctl", "-n", key], capture_output=True, text=True)
return r.stdout.strip() if r.returncode == 0 else None
model = sysctl("machdep.cpu.brand_string")
freq_ghz, freq_source = None, "unknown"
m = re.search(r"@\s*([\d.]+)\s*GHz", model or "")
if m:
freq_ghz, freq_source = float(m.group(1)), "model name"
cores = sysctl("hw.physicalcpu")
p_cores, e_cores = sysctl("hw.perflevel0.physicalcpu"), sysctl("hw.perflevel1.physicalcpu")
if p_cores and e_cores:
cores = f"{p_cores}P+{e_cores}E"
mem = sysctl("hw.memsize")
return {"cpu_model": model or "unknown", "cpu_base_ghz": freq_ghz, "cpu_base_source": freq_source,
"sockets": int(sysctl("hw.packages") or 1), "physical_cores": cores,
"threads": int(sysctl("hw.logicalcpu") or os.cpu_count()),
"memory_gib": int(mem) / 1024 ** 3 if mem else None, "gpus": []}
def hardware_info():
"""The run host's hardware, for the manifest: CPU model, nominal/base frequency (and where it
came from), physical cores, threads, sockets, memory, GPUs. Linux is detailed; macOS is a short
best-effort; anywhere else this is just empty, and the report says so."""
try:
if sys.platform == "darwin":
return macos_hardware()
if sys.platform.startswith("linux"):
return linux_hardware()
except OSError:
pass
return {}
# ------------------------------------------------------------------ running
def command(binary, e, opts, model=None):
@@ -377,7 +471,8 @@ def run_sets(site, sets, arms, binary_src, build_dir, label, opts, subset, basel
"binary": info,
"runner_git": git(HERE, "rev-parse", "--short", "HEAD") or "unknown",
"runner_dirty": bool(git(HERE, "status", "--porcelain", "--", ".")),
"host": socket.gethostname(), "pid": os.getpid(), "start": datetime.datetime.now().isoformat(timespec="seconds"),
"host": socket.gethostname(), "hardware": hardware_info(), "pid": os.getpid(),
"start": datetime.datetime.now().isoformat(timespec="seconds"),
"end": None, "complete": False, "results_schema": report.RESULTS_SCHEMA, "options": {k: v for k, v in opts.items() if k != "runs_root"},
"gpu_shared": bool(opts["gpulock"]), "sets": sets}
write_json(os.path.join(run_dir, "manifest.json"), man)
+14
View File
@@ -288,6 +288,19 @@ def status(r):
return "accepted_alt" if r.get("cause") == "accepted_alternative" else r["verdict"]
def hardware_line(man):
"""One line for the report header; old runs have no "hardware" key."""
hw = man.get("hardware")
if not hw:
return "hardware: not recorded"
freq = f"{hw['cpu_base_ghz']:.2f} GHz nominal ({hw['cpu_base_source']})" if hw.get("cpu_base_ghz") else \
f"nominal frequency unknown ({hw.get('cpu_base_source', 'unknown')})"
cores = f"{f(hw.get('physical_cores'), '{}')}C/{hw.get('threads') or '?'}T, {f(hw.get('sockets'), '{}')} socket(s)"
mem = f"{hw['memory_gib']:.0f} GiB RAM" if hw.get("memory_gib") else "RAM unknown"
gpus = ", ".join(f"{g['name']} ({g['memory']})" for g in hw.get("gpus") or []) or "none"
return f"hardware: {hw.get('cpu_model', 'unknown')}, {freq}, {cores}, {mem}, GPU: {gpus}"
def rate(rs):
s = scored(rs)
n = sum(r["verdict"] == "pass" for r in s)
@@ -316,6 +329,7 @@ def build(run_dir, baseline=None, allow_incomplete=False):
doc.ul([
f"rugnux {b.get('version', '?')}, sha256 {b['sha256'][:16]}, build flags: {b.get('flags') or 'unknown'}",
f"runner {man['runner_git']}, host {man['host']}, {man['start']} -> {man.get('end') or 'NOT FINISHED'}",
hardware_line(man),
f"arms: {', '.join(man['arms'])}; {len(man['sets'])} sets"
+ (f" (subset: {man['subset']})" if man.get("subset") else " (full arm)"),
"timing: NOT a reference - the GPU was shared" if man.get("gpu_shared")