Files
VoxelForge/Standalone/Research/WorldAssemblerM3/Linux78/RunL78HashMatrix.py
T
Fr0zkaandClaude Opus 5.5 ec20994a8e streaming: near LODs first (walkable ring, LOD0, LOD1, LOD2, then far); exact passage trims (L78)
- Headless and Unreal schedulers drain the collision-critical ring, then LOD0-2, then far LODs
  at low priority. LOD0-2 ready (W8 medians): SW 4.36->1.76, FI 6.89->5.26, TN 4.88->3.22,
  VS 2.71->1.56 s. Whole view roughly unchanged (FI/VS slightly later).
  KNOWN RISK: far tiles wait until every near tile is ready, so far LODs may starve while
  moving fast (to address next).
- Exact composer trims: tile-level upper-mouth candidate list, segment-index min/max rejection
  before lower_bound, 64-entry thread-local value-noise corner cache. Passage share 65 -> 63%.
- World exact: 24/24 hash matrix + pinned L75 owner hash. Fast tier PASS. Linux UE host builds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dhxM43dnWvUu2B5Ph1iG1
2026-10-27 19:13:45 +01:00

117 lines
4.6 KiB
Python

#!/usr/bin/env python3
"""Compare L78 exact tile hashes with the retained L76/L77-equivalent matrix."""
from __future__ import annotations
import json
import re
import subprocess
import time
from pathlib import Path
ROOT = Path(__file__).resolve().parents[4]
OUT = ROOT / "Saved/Linux/l78/hashes"
DATA = ROOT / "Standalone/data/owner_world.json"
BINARIES = {
"clang": ROOT / "Saved/Linux/l78/bin/VoxelForgeCoreHeadless-l78-clang",
"gcc": ROOT / "Saved/Linux/l78/bin/VoxelForgeCoreHeadless-l78-gcc",
}
CAMERAS = {
0: (8.0, 16.0, -372.2626953125),
1: (25.8369140625, 3.19921875, -737.0),
2: (19.166015625, -14.2001953125, -753.3740234375),
3: (-20.0625, -5.068359375, -900.353515625),
}
HASH = re.compile(
r"^\[PipelineTileHash\] lod=(\d+) x=(-?\d+) y=(-?\d+) z=(-?\d+) "
r"density=(0x[0-9a-fA-F]+) mesh=(0x[0-9a-fA-F]+) "
r"payload=(0x[0-9a-fA-F]+) topology=(0x[0-9a-fA-F]+)$",
re.M,
)
def read_hashes(path: Path) -> dict[tuple[int, int, int, int], tuple[str, ...]]:
content = path.read_text(encoding="utf-8", errors="replace")
return {
tuple(int(match.group(i)) for i in range(1, 5)):
tuple(value.lower() for value in match.groups()[4:])
for match in HASH.finditer(content)
}
def run(compiler: str, workers: int, strate: int) -> dict:
OUT.mkdir(parents=True, exist_ok=True)
log = OUT / compiler / f"w{workers}" / f"strate{strate}-after.log"
log.parent.mkdir(parents=True, exist_ok=True)
camera = ",".join(f"{value:.12f}" for value in CAMERAS[strate]) + ",0,0"
command = [
"taskset", "-c", "0-11", "prlimit", "--as=6442450944", "--",
"timeout", "1740s", str(BINARIES[compiler]), str(DATA),
"--world-assembler-prototype", "--stream-benchmark", "--stream-pipeline",
"--force-generate", f"--workers={workers}", "--clip-radius=3",
"--max-clip-level=8", "--max-level=8", f"--camera={camera}",
"--stream-hash-tiles",
]
started = time.monotonic()
with log.open("w", encoding="utf-8") as output:
result = subprocess.run(command, cwd=ROOT, stdout=output,
stderr=subprocess.STDOUT, check=False, timeout=1740)
hashes = read_hashes(log)
if result.returncode != 0 or not hashes:
raise SystemExit(f"hash generation failed: {log}; exit={result.returncode}")
reference = ROOT / "Saved/Linux/l76/hashes" / compiler / f"w{workers}" / f"strate{strate}-before.log"
expected = read_hashes(reference)
missing, extra = expected.keys() - hashes.keys(), hashes.keys() - expected.keys()
mismatches = {name: 0 for name in ("density", "mesh", "payload", "topology")}
examples = []
for key in sorted(expected.keys() & hashes.keys()):
for index, name in enumerate(mismatches):
if expected[key][index] != hashes[key][index]:
mismatches[name] += 1
if len(examples) < 12:
examples.append({"tile": key, "field": name,
"before": expected[key][index],
"after": hashes[key][index]})
row = {
"compiler": compiler,
"workers": workers,
"strate": strate,
"exit_code": result.returncode,
"wall_s": round(time.monotonic() - started, 3),
"expected_tiles": len(expected),
"candidate_tiles": len(hashes),
"missing_keys": len(missing),
"extra_keys": len(extra),
"mismatches": mismatches,
"examples": examples,
"equal": not missing and not extra and not any(mismatches.values()),
"reference": str(reference.relative_to(ROOT)),
"log": str(log.relative_to(ROOT)),
}
print("[L78HashCompare] " + json.dumps(row, sort_keys=True), flush=True)
return row
def main() -> int:
missing = [str(path) for path in (DATA, *BINARIES.values()) if not path.is_file()]
if missing:
raise SystemExit("missing input: " + ", ".join(missing))
rows = []
for compiler in ("clang", "gcc"):
for workers in (1, 8, 12):
for strate in range(4):
row = run(compiler, workers, strate)
rows.append(row)
(OUT / "summary-partial.json").write_text(
json.dumps(rows, indent=2) + "\n", encoding="utf-8")
if not row["equal"]:
raise SystemExit(f"hash mismatch; see {row['log']}")
result = {"comparisons": rows, "equal": all(row["equal"] for row in rows)}
(OUT / "summary.json").write_text(json.dumps(result, indent=2) + "\n",
encoding="utf-8")
return 0
if __name__ == "__main__":
raise SystemExit(main())