#!/usr/bin/env python3 """One 30 m/s headless movement run for the UE-only region gate experiment.""" from __future__ import annotations import json import math import re import subprocess import time from pathlib import Path ROOT = Path(__file__).resolve().parents[4] DATA = ROOT / "Standalone/data/owner_world.json" BIN = ROOT / "Saved/Linux/l108/bin/VoxelForgeCoreHeadless-l108-after-clang" OUT = ROOT / "Saved/Linux/l123/headless" SAMPLE = re.compile(r"^\[L79MovingSample\] (.*)$", re.M) SUMMARY = re.compile(r"^\[L79MovingSummary\] (.*)$", re.M) FIELDS = re.compile(r"([a-zA-Z0-9_]+)=([^ ]+)") def p99(values: list[float]) -> float | None: if not values: return None values.sort() return values[max(0, math.ceil(0.99 * len(values)) - 1)] def main() -> int: OUT.mkdir(parents=True, exist_ok=True) log = OUT / "movement-30mps-r1.log" camera = "19.166015625000,-14.200195312500,-753.374023437500,0,0" command = [ "taskset", "-c", "0-11", "prlimit", "--as=6442450944", "--", "timeout", "1740s", str(BIN), str(DATA), "--world-assembler-prototype", "--stream-benchmark", "--stream-pipeline", "--workers=8", "--clip-radius=3", "--max-clip-level=8", "--max-level=8", f"--camera={camera}", "--profile-lod-work", "--stream-scheduler-policy=3", "--moving-camera-speed-mps=30.0", "--moving-camera-duration-s=12", "--moving-camera-dwell-s=5", ] started = time.monotonic() with log.open("w", encoding="utf-8") as stream: process = subprocess.run(command, cwd=ROOT, stdout=stream, stderr=subprocess.STDOUT, check=False, timeout=1740) content = log.read_text(encoding="utf-8", errors="replace") rows = [] for match in SAMPLE.finditer(content): row = dict(FIELDS.findall(match.group(1))) for name in ("near_ready_pct", "far_hole_pct", "queue_update_ms"): if name in row: row[name] = float(row[name]) row["phase"] = row.get("phase", "move") rows.append(row) summary = dict(FIELDS.findall(SUMMARY.search(content).group(1))) if SUMMARY.search(content) else {} moving = [row for row in rows if row["phase"] == "move"] updates = [row["queue_update_ms"] for row in moving if "queue_update_ms" in row] result = { "exit_code": process.returncode, "wall_s": round(time.monotonic() - started, 3), "moving_samples": len(moving), "near_ready_moving_mean_pct": sum(r["near_ready_pct"] for r in moving) / max(1, len(moving)), "far_holes_moving_mean_pct": sum(r["far_hole_pct"] for r in moving) / max(1, len(moving)), "update_work_p99_ms": p99(updates), "update_work_max_ms": max(updates, default=None), "generation_failures": int(summary.get("generation_failures", -1)), "log": str(log.relative_to(ROOT)), } (OUT / "summary.json").write_text(json.dumps(result, indent=2) + "\n", encoding="utf-8") print("[L123Headless] " + json.dumps(result, sort_keys=True), flush=True) if process.returncode or not moving or result["generation_failures"] != 0: return 1 return 0 if __name__ == "__main__": raise SystemExit(main())