Files
VoxelForge/Standalone/Research/WorldAssemblerM3/Linux104/RunL104ReadinessPairs.py
T
Fr0zkaandClaude Opus 5.5 6a80cb0ab3 far shells: 3D cell bins for HasDownwardHit/HasUpwardHit candidates (L104, exact)
Near tiles legitimately need floor/ceiling boundary patches, but every hit query scanned the
tile's whole XY column. Direction-specific 3D cell bins conservatively index triangle bounds; the
existing predicates still decide every hit. Candidate visits per query -88..-99%; identical query
and hit counts. Hit-function cost ~1.7-1.9 -> ~0.35 s per FI/TN run. Near-ready @W12: FI 1.63 ->
1.52, TN 1.51 -> 1.38, VS 1.00 -> 0.92 s. All tile/whole hashes equal L103 (Clang/GCC W1/W8/W12).
The 24-28% "idle" is in the serial base-shape (~0.24 s) and far-parent (~0.13 s) phases; the
LOD0-1 drain is >= 99.4% busy. Fast tier PASS; Linux UE builds; FI Unreal arrival 1.96-1.98 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dhxM43dnWvUu2B5Ph1iG1
2026-10-28 20:34:24 +01:00

133 lines
6.9 KiB
Python

#!/usr/bin/env python3
"""Interleaved L103/L104 near and whole-view readiness at W8/W12."""
from __future__ import annotations
import json
import re
import statistics
import subprocess
import time
from pathlib import Path
ROOT = Path(__file__).resolve().parents[4]
OUT = ROOT / "Saved/Linux/l104/readiness-paired"
DATA = ROOT / "Standalone/data/owner_world.json"
BINARIES = {
"before": ROOT / "Saved/Linux/l101/bin/VoxelForgeCoreHeadless-l101-clang",
"after": ROOT / "Saved/Linux/l104/bin/VoxelForgeCoreHeadless-l104-clang",
}
STAMPS = {
"before": "c5f49a45f51856b857a1ee8877b7d777208e67daf64281caefc7ef84e8006410",
"after": "b23900c9d2ee10b0ee29bec1b1b7f74ee3fa697f5c66682e808b19ad9c334780",
}
STRATA = {
"SW": {"camera": (8.0, 16.0, -372.2626953125), "near": 1408, "whole": 2850},
"FI": {"camera": (25.8369140625, 3.19921875, -737.0), "near": 1216, "whole": 2249},
"TN": {"camera": (19.166015625, -14.2001953125, -753.3740234375), "near": 1344, "whole": 2233},
"VS": {"camera": (-20.0625, -5.068359375, -900.353515625), "near": 1344, "whole": 2329},
}
NEAR = re.compile(r"^\[WorldAssemblerNearLODReady\] lods=0-2 tiles=(\d+)/(\d+) cold_ready_s=([0-9.]+)$", re.M)
PUBLISHED = re.compile(r"^\[WorldAssemblerNearLODPublished\] lods=0-2 tiles=(\d+)/(\d+) cold_ready_s=([0-9.]+)$", re.M)
PIPELINE_READY = re.compile(r"^\[WorldAssemblerNearLODPipelineReady\] lods=0-2 tiles=(\d+)/(\d+) cold_ready_s=([0-9.]+)$", re.M)
PIPELINE = re.compile(r"^\[StreamPipeline\] (.*)$", re.M)
CONFIG = re.compile(r"^\[HeadlessConfig\] (.*)$", re.M)
STAMP = re.compile(r"^\[VoxelForgeSourceStamp\] sha256=(\S+)$", re.M)
FIELDS = re.compile(r"([a-zA-Z0-9_]+)=([^ ]+)")
def run(stratum: str, workers: int, build: str, phase: str, replicate: int) -> dict:
OUT.mkdir(parents=True, exist_ok=True)
suffix = f"-r{replicate}" if phase == "measured" else ""
log = OUT / f"{stratum.lower()}-w{workers}-{build}-{phase}{suffix}.log"
camera = ",".join(f"{value:.12f}" for value in STRATA[stratum]["camera"]) + ",0,0"
command = [
"taskset", "-c", "0-11", "prlimit", "--as=6442450944", "--", "env",
f"VOXELFORGE_L104_FAR_HIT_CACHE={0 if build == 'before' else 1}",
"timeout", "1740s", str(BINARIES[build]), 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",
]
started = time.monotonic()
with log.open("w", encoding="utf-8") as stream:
result = subprocess.run(command, cwd=ROOT, stdout=stream, stderr=subprocess.STDOUT,
check=False, timeout=1740)
content = log.read_text(encoding="utf-8", errors="replace")
near, published, ready = NEAR.search(content), PUBLISHED.search(content), PIPELINE_READY.search(content)
pipeline, config, stamp = PIPELINE.search(content), CONFIG.search(content), STAMP.search(content)
if result.returncode or not all((near, published, ready, pipeline, config, stamp)):
raise RuntimeError(f"readiness run failed or markers missing: {log}; exit={result.returncode}")
if stamp.group(1) != STAMPS[build]:
raise RuntimeError(f"source stamp mismatch: {log}: {stamp.group(1)}")
spec = STRATA[stratum]
config_fields = dict(FIELDS.findall(config.group(1)))
if int(config_fields["workers"]) != workers:
raise RuntimeError(f"worker mismatch: {log}")
for marker in (near, published, ready):
if (int(marker.group(1)), int(marker.group(2))) != (spec["near"], spec["near"]):
raise RuntimeError(f"incomplete near set: {log}: {marker.group(1)}/{marker.group(2)}")
pipeline_fields = dict(FIELDS.findall(pipeline.group(1)))
whole_done, whole_total = (int(value) for value in pipeline_fields["whole_tiles"].split("/"))
if (whole_done, whole_total) != (spec["whole"], spec["whole"]):
raise RuntimeError(f"incomplete whole set: {log}: {whole_done}/{whole_total}")
row = {
"stratum": stratum, "workers": workers, "build": build, "phase": phase,
"replicate": replicate, "exit_code": result.returncode,
"source_stamp": stamp.group(1), "near_tiles": spec["near"], "whole_tiles": whole_done,
"lod02_ready_s": float(near.group(3)),
"lod02_published_s": float(published.group(3)),
"lod02_pipeline_ready_s": float(ready.group(3)),
"whole_view_ready_s": float(pipeline_fields["whole_view_ready"].removesuffix("s")),
"shape_s": float(pipeline_fields["shape"].removesuffix("s")),
"far_shape_s": float(pipeline_fields["far_shape"].removesuffix("s")),
"wall_s": round(time.monotonic() - started, 3),
"log": str(log.relative_to(ROOT)),
}
print("[L104ReadinessRun] " + json.dumps(row, sort_keys=True), flush=True)
return row
def main() -> int:
for binary in BINARIES.values():
if not binary.is_file():
raise SystemExit(f"missing binary: {binary}")
if not DATA.is_file():
raise SystemExit(f"missing owner input: {DATA}")
cells = [(stratum, workers) for stratum in ("VS", "TN", "FI", "SW")
for workers in (12, 8)]
for stratum, workers in cells:
for build in ("before", "after"):
run(stratum, workers, build, "warmup", 0)
orders = (("before", "after"), ("after", "before"), ("before", "after"))
rows = []
for stratum, workers in cells:
for replicate, order in enumerate(orders, 1):
for build in order:
rows.append(run(stratum, workers, build, "measured", replicate))
(OUT / "runs-partial.json").write_text(json.dumps(rows, indent=2) + "\n",
encoding="utf-8")
summary = []
for stratum in STRATA:
for workers in (8, 12):
group = [row for row in rows if row["stratum"] == stratum and row["workers"] == workers]
item = {"stratum": stratum, "workers": workers, "measured_runs_per_build": 3}
for build in ("before", "after"):
subset = [row for row in group if row["build"] == build]
if len(subset) != 3:
raise RuntimeError(f"expected 3 measured runs: {stratum} W{workers} {build}")
for metric in ("lod02_ready_s", "whole_view_ready_s"):
values = [row[metric] for row in subset]
item[f"{build}_{metric}"] = values
item[f"{build}_{metric}_median"] = statistics.median(values)
for metric in ("lod02_ready_s", "whole_view_ready_s"):
item[f"{metric}_delta_pct"] = 100 * (
item[f"after_{metric}_median"] / item[f"before_{metric}_median"] - 1)
summary.append(item)
result = {"runs": rows, "summary": summary}
(OUT / "summary.json").write_text(json.dumps(result, indent=2) + "\n", encoding="utf-8")
return 0
if __name__ == "__main__":
raise SystemExit(main())