Files
VoxelForge/Standalone/Research/WorldAssemblerM3/Linux140/RunL140Timing.py
T
Fr0zkaandClaude Opus 5.5 4f93f3fffb research: Floating Islands planned around fixed tunnels (L140, 0/16; kept as patch)
Native FI binds and its own route/clearance/mouth-support checks pass on seeds 0 and 10, but 14/16 seeds have no
island arrangement that clears the fixed passage tubes and reaches both mouth heights; seed 10 has one composed
collision; ripple 6-7 cm vs the 3.5 cm limit on both upper passages. Third failure of the 'islands adapt to fixed
tunnels' premise (L133 x2, L140).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dhxM43dnWvUu2B5Ph1iG1
2026-11-01 08:08:40 +01:00

154 lines
7.7 KiB
Python

#!/usr/bin/env python3
"""L80 timing: native L140 vs L139 HEAD and assembler/world, all owner strata."""
from __future__ import annotations
import json
import os
import re
import statistics
import subprocess
import time
from pathlib import Path
ROOT = Path(__file__).resolve().parents[4]
OUT = ROOT / "Saved/Linux/l140/timing"
DATA = ROOT / "Standalone/data/owner_world.json"
BINARIES = {
"assembler-world": (
ROOT / "Saved/Linux/l137/bin/VoxelForgeCoreHeadless-l137-aa-a",
"4499fb2a8a4ede7d6cbc68d1b794f104658cdaae93ed9cacbc91fe7ff3fc3621"),
"head": (
ROOT / "Saved/Linux/l139/bin/VoxelForgeCoreHeadless-l139-clang",
"b8603b6cb3975ca0f9669759e4e2464561c557fdb7aa6836acef123ecf0b99d1"),
"l140-native-fi": (
ROOT / "Saved/Linux/l140/bin/VoxelForgeCoreHeadless-l140-clang",
"6205e6c180ef32c41792dc3e0d8bf443a96df41974f40334af4bf3a157ab88da"),
}
CAMERAS = {
# The camera override also selects the owner SurfaceWorld departure mouth.
# Hold XY to the seed-0 native-FI valid mouth so every layer/version shares one layout.
0: (25.8369140625, 3.19921875, -372.2626953125),
1: (25.8369140625, 3.19921875, -737.0),
2: (25.8369140625, 3.19921875, -753.3740234375),
3: (25.8369140625, 3.19921875, -900.353515625),
}
PIPELINE_RE = re.compile(r"^\[StreamPipeline\] (.*)$", re.M)
FIELDS_RE = re.compile(r"([a-zA-Z0-9_]+)=([^ ]+)")
NEAR_RE = re.compile(
r"^\[WorldAssemblerNearLODReady\] lods=0-2 tiles=(\d+)/(\d+) cold_ready_s=([0-9.]+)$",
re.M)
STAMP_RE = re.compile(r"^\[VoxelForgeSourceStamp\] sha256=([0-9a-f]{64})$", re.M)
L140_AA_FLOOR_PCT = 1.0 # L137's same-binary A/A median control.
def quiet_machine() -> tuple[float, float]:
load_1m = os.getloadavg()[0]
def totals() -> tuple[int, int]:
fields = Path("/proc/stat").read_text().splitlines()[0].split()
values = [int(value) for value in fields[1:]]
return sum(values), values[3] + values[4]
before = totals()
time.sleep(2.0)
after = totals()
idle = 100.0 * (after[1] - before[1]) / max(1, after[0] - before[0])
return load_1m, idle
def run(strate: int, workers: int, version: str, phase: str, replicate: int) -> dict[str, object]:
binary, expected_stamp = BINARIES[version]
camera = ",".join(f"{value:.12f}" for value in CAMERAS[strate]) + ",0,0"
label = f"s{strate}-w{workers}-{version}-{phase}{replicate}"
log = OUT / f"{label}.log"
command = ["taskset", "-c", "0-11", "prlimit", "--as=6442450944", "--",
"timeout", "1740s", str(binary), str(DATA), "--world-assembler-prototype",
"--stream-benchmark", "--stream-pipeline", f"--workers={workers}",
"--clip-radius=3", "--max-clip-level=8", "--max-level=8",
f"--camera={camera}", "--profile-lod-work", "--stream-scheduler-policy=3",
"--recipe=surface-world"]
if version == "l140-native-fi":
command.append("--native-owner-fi")
started = time.monotonic()
with log.open("w", encoding="utf-8") as output:
proc = subprocess.run(command, cwd=ROOT, stdout=output,
stderr=subprocess.STDOUT, check=False, timeout=1740)
content = log.read_text(encoding="utf-8", errors="replace")
pipeline, near, stamp = PIPELINE_RE.search(content), NEAR_RE.search(content), STAMP_RE.search(content)
if (proc.returncode or pipeline is None or near is None or stamp is None
or stamp.group(1) != expected_stamp):
raise SystemExit(f"L80 run failed or stamp mismatch: {log}; exit={proc.returncode}")
if version == "l140-native-fi" and not re.search(
r"^\[FloatingIslandWorldAssembly\].*dispatch=FloatingIslands-native .*status=PASS$",
content, re.M):
raise SystemExit(f"candidate timing did not bind native FloatingIslands: {log}")
fields = dict(FIELDS_RE.findall(pipeline.group(1)))
row = {"strate": strate, "workers": workers, "version": version,
"phase": phase, "replicate": replicate, "source_stamp": stamp.group(1),
"lod02_ready_s": float(near.group(3)),
"whole_view_ready_s": float(fields["whole_view_ready"].removesuffix("s")),
"whole_tiles": int(fields["whole_tiles"].split("/")[0]),
"wall_s": round(time.monotonic() - started, 3), "log": str(log.relative_to(ROOT))}
print("[L140TimingRun] " + json.dumps(row, sort_keys=True), flush=True)
return row
def main() -> int:
if any(not path.is_file() for path, _ in BINARIES.values()) or not DATA.is_file():
raise SystemExit("missing L80 timing binaries or owner fixture")
OUT.mkdir(parents=True, exist_ok=True)
load_1m, idle = quiet_machine()
(OUT / "machine-load-before.txt").write_text(
f"1-minute load: {load_1m:.2f}\n2-second CPU idle: {idle:.1f}%\n")
print(f"[L140TimingGate] load_1m={load_1m:.2f} cpu_idle_2s={idle:.1f}%", flush=True)
if load_1m >= 1.5 or idle < 97.0:
raise SystemExit("timing refused: machine is above the L80 quiet-load gate")
rows: list[dict[str, object]] = []
for strate in range(4):
for workers in (8, 12):
for version in BINARIES:
run(strate, workers, version, "warmup", 0)
for replicate in range(1, 6):
order = tuple(BINARIES)
order = order[replicate % len(order):] + order[:replicate % len(order)]
if replicate % 2 == 0:
order = tuple(reversed(order))
for version in order:
rows.append(run(strate, workers, version, "measured", replicate))
(OUT / "runs-partial.json").write_text(json.dumps(rows, indent=2) + "\n")
measured = [row for row in rows if row["phase"] == "measured"]
summary = []
for strate in range(4):
for workers in (8, 12):
group = [row for row in measured if row["strate"] == strate and row["workers"] == workers]
medians = {version: {key: statistics.median(
row[key] for row in group if row["version"] == version)
for key in ("lod02_ready_s", "whole_view_ready_s")} for version in BINARIES}
entry: dict[str, object] = {"strate": strate, "workers": workers,
"replicates_per_version": 5, "medians": medians}
for key in ("lod02_ready_s", "whole_view_ready_s"):
for baseline in ("head", "assembler-world"):
entry[f"l140_vs_{baseline}_{key}_delta_pct"] = round(
100.0 * (medians["l140-native-fi"][key] / medians[baseline][key] - 1.0), 2)
entry[f"l140_vs_{baseline}_{key}_paired_deltas_pct"] = [round(100.0 * (
next(row[key] for row in group if row["version"] == "l140-native-fi"
and row["replicate"] == replicate)
/ next(row[key] for row in group if row["version"] == baseline
and row["replicate"] == replicate) - 1.0), 3)
for replicate in range(1, 6)]
summary.append(entry)
result = {"a_a_noise_floor_pct": L140_AA_FLOOR_PCT,
"a_a_reference": "L137 same-binary median control; assembler/world source stamp",
"timing_protocol": "quiet machine; one warm-up per binary per cell; five interleaved measured runs; W8/W12; all four owner layers",
"machine": {"load_1m": load_1m, "cpu_idle_2s_pct": idle},
"source_stamps": {name: stamp for name, (_path, stamp) in BINARIES.items()},
"runs": rows, "summary": summary}
(OUT / "summary.json").write_text(json.dumps(result, indent=2) + "\n")
print(f"[L140TimingSummary] measured_runs={len(measured)} warmups=24 aa_floor_pct=1.0 status=PASS",
flush=True)
return 0
if __name__ == "__main__":
raise SystemExit(main())