#!/usr/bin/env python3 """Interleave five W12 hash-off whole-view cost triplets for L24/L29/L30.""" import re import subprocess import time from pathlib import Path ROOT = Path(__file__).resolve().parents[4] OUT = ROOT / "Saved/Linux/l30" OUT.mkdir(parents=True, exist_ok=True) BINARIES = { "l24": ROOT / "Saved/Linux/l24-source/bin/linux/VoxelForgeCoreHeadless-linux24-clang19", "l29": ROOT / "Saved/Linux/bin/VoxelForgeCoreHeadless-linux29-clang", "l30": ROOT / "Saved/Linux/l30/bin/VoxelForgeCoreHeadless-linux30-speed-fade", } ORDERS = ( ("l24", "l29", "l30"), ("l29", "l30", "l24"), ("l30", "l24", "l29"), ("l24", "l30", "l29"), ("l29", "l24", "l30"), ) WHOLE_READY = re.compile(r"\bwhole_view_ready=([0-9.]+)s") rows = [] for recipe in ("surface-world", "floating-islands"): for pair, order in enumerate(ORDERS, 1): for build in order: name = f"cost-speedfade-{recipe}-pair{pair}-{build}" logfile = OUT / f"{name}.log" command = [ "prlimit", "--as=6442450944", "--", str(BINARIES[build]), str(ROOT / "Standalone/data/owner_world.json"), "--workers=12", "--world-assembler-prototype", "--stream-benchmark", "--stream-pipeline", "--force-generate", "--clip-radius=3", "--max-clip-level=8", "--max-level=-1", f"--recipe={recipe}", ] started = time.monotonic() with logfile.open("w", encoding="utf-8") as stream: subprocess.run(command, stdout=stream, stderr=subprocess.STDOUT, check=True, timeout=1800) elapsed = time.monotonic() - started text = logfile.read_text(encoding="utf-8", errors="replace") matches = WHOLE_READY.findall(text) if len(matches) != 1 or "hash=off" not in text or "cache_hits=0" not in text: raise SystemExit(f"invalid cost run: {name}; see {logfile}") ready = float(matches[0]) rows.append((recipe, pair, build, ready, elapsed)) print(f"{recipe} pair={pair} build={build} whole_view_ready={ready:.3f}s " f"process_elapsed={elapsed:.3f}s", flush=True) summary = OUT / "cost-runs-speedfade.csv" summary.write_text("recipe,pair,build,whole_view_ready_seconds,process_elapsed_seconds\n" + "".join(f"{recipe},{pair},{build},{ready:.6f},{elapsed:.6f}\n" for recipe, pair, build, ready, elapsed in rows), encoding="utf-8") print(f"wrote {summary}", flush=True)