Files
VoxelForge/Standalone/Research/WorldAssemblerM3/Linux83/RunL83SerialFloor.py
T
Fr0zkaandClaude Opus 5.5 a81b5b7d06 passages: contiguous BVH node ranges + child-bound reuse (L83); scaling and serial floor measured
Exact through LOD2 (all near tile hashes equal L82). W8 LOD0-2: SW 1.09->1.06, FI 2.47->2.34,
TN 2.39->2.43 (noise), VS 1.20->1.18 s. Fast tier PASS.
Scaling W4/W8/W12/W16 (LOD0-2, FI): 3.59 / 2.48 / 2.33 / 2.34 s - flattens past W8-W12.
Estimated infinite-worker floor ~1.0 s FI/TN = shape compile (0.35-0.41 s, not overlapped:
no shape-free tiles in these views) + slowest single LOD0 tile service (0.51-0.59 s).

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

113 lines
5.5 KiB
Python

#!/usr/bin/env python3
"""Estimate the LOD0-2 infinite-worker floor from instrumented FI/TN tile timelines."""
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/l83/serial-floor"
DATA = ROOT / "Standalone/data/owner_world.json"
BINARY = ROOT / "Saved/Linux/l83/profile-bin/VoxelForgeCoreHeadless-l83-profile-clang19"
CAMERAS = {
1: (25.8369140625, 3.19921875, -737.0),
2: (19.166015625, -14.2001953125, -753.3740234375),
}
STRATE_NAMES = {1: "FI", 2: "TN"}
EXPECTED_NEAR = {1: 1216, 2: 1344}
EXPECTED_STAMP = "08af4e98c86a69477cc79e21463d8c93bcd11ebe0f077d7c11519031d9141fa9"
PIPELINE = re.compile(r"^\[StreamPipeline\] (.*)$", re.M)
FIELDS = re.compile(r"([a-zA-Z0-9_]+)=([^ ]+)")
NEAR = re.compile(r"^\[WorldAssemblerNearLODReady\] lods=0-2 tiles=(\d+)/(\d+) cold_ready_s=([0-9.]+)$", re.M)
SHAPE_FREE = re.compile(r"^\[ShapeReadiness\] shape_free_desired=(\d+)/(\d+) near_ring=(\d+)/27", re.M)
STAMP = re.compile(r"^\[VoxelForgeSourceStamp\] sha256=(\S+)$", re.M)
FINISH = re.compile(
r"^\[CpuTileTimeline\] event=finish key=\((-?\d+),(-?\d+),(-?\d+),lod(\d+)\) "
r"at_ms=([0-9.]+).*?queued_ms=([0-9.]+) dispatch_ms=([0-9.]+) finish_ms=([0-9.]+) "
r"service_ms=([0-9.]+) worker_ms=([0-9.]+)$", re.M)
def run(strate: int) -> dict:
OUT.mkdir(parents=True, exist_ok=True)
log = OUT / f"{STRATE_NAMES[strate].lower()}-w16.log"
camera = ",".join(f"{v:.12f}" for v in CAMERAS[strate]) + ",0,0"
command = [
"taskset", "-c", "0-11", "prlimit", "--as=6442450944", "--",
"timeout", "1740s", str(BINARY), str(DATA), "--world-assembler-prototype",
"--stream-benchmark", "--stream-pipeline", "--workers=16", "--clip-radius=3",
"--max-clip-level=8", "--max-level=8", f"--camera={camera}",
"--profile-lod-work", "--instrument-tile-drain",
]
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)
output = log.read_text(encoding="utf-8", errors="replace")
pipeline_match, near_match = PIPELINE.search(output), NEAR.search(output)
free_match, stamp_match = SHAPE_FREE.search(output), STAMP.search(output)
if result.returncode or pipeline_match is None or near_match is None:
raise RuntimeError(f"serial-floor run failed: exit={result.returncode} {log}")
if stamp_match is None or stamp_match.group(1) != EXPECTED_STAMP:
raise RuntimeError(f"source stamp mismatch in {log}")
pipeline = dict(FIELDS.findall(pipeline_match.group(1)))
near_done, near_total = int(near_match.group(1)), int(near_match.group(2))
if near_done != near_total or near_total != EXPECTED_NEAR[strate]:
raise RuntimeError(f"incomplete near tiles in {log}: {near_done}/{near_total}")
events = []
for match in FINISH.finditer(output):
lod = int(match.group(4))
if lod > 2:
continue
events.append({
"lod": lod, "finish_ms": float(match.group(5)), "queued_ms": float(match.group(6)),
"dispatch_ms": float(match.group(7)), "service_ms": float(match.group(9)),
"worker_ms": float(match.group(10)),
})
if len(events) != EXPECTED_NEAR[strate]:
raise RuntimeError(f"near timeline events incomplete in {log}: {len(events)}/{EXPECTED_NEAR[strate]}")
floors = [event["queued_ms"] + event["service_ms"] for event in events]
by_lod = {}
for lod in range(3):
subset = [event for event in events if event["lod"] == lod]
if subset:
by_lod[lod] = {
"tiles": len(subset),
"max_service_ms": max(event["service_ms"] for event in subset),
"max_wait_ms": max(event["dispatch_ms"] - event["queued_ms"] for event in subset),
"last_actual_finish_ms": max(event["finish_ms"] for event in subset),
"max_enqueue_plus_service_ms": max(e["queued_ms"] + e["service_ms"] for e in subset),
}
row = {
"strate": strate, "name": STRATE_NAMES[strate], "workers": 16,
"exit_code": result.returncode, "wall_s": round(time.monotonic() - started, 3),
"near_tiles": near_total, "lod02_ready_s": float(near_match.group(3)),
"shape_s": float(pipeline["shape"].removesuffix("s")),
"shape_free_desired": int(free_match.group(1)) if free_match else None,
"shape_free_near_ring": int(free_match.group(3)) if free_match else None,
"infinite_worker_floor_estimate_s": round(max(floors) / 1000.0, 6),
"max_near_service_ms": max(event["service_ms"] for event in events),
"last_near_enqueue_ms": max(event["queued_ms"] for event in events),
"max_near_enqueue_plus_service_ms": max(floors),
"max_near_queue_wait_ms": max(event["dispatch_ms"] - event["queued_ms"] for event in events),
"per_lod": by_lod, "source_stamp": stamp_match.group(1),
"log": str(log.relative_to(ROOT)),
}
print("[L83SerialFloor] " + json.dumps(row, sort_keys=True), flush=True)
return row
def main() -> int:
for path in (BINARY, DATA):
if not path.is_file():
raise SystemExit(f"missing input: {path}")
rows = [run(strate) for strate in (1, 2)]
(OUT / "summary.json").write_text(json.dumps(rows, indent=2) + "\n", encoding="utf-8")
return 0
if __name__ == "__main__":
raise SystemExit(main())