Environment-only diagnostic hook disables passage composition (never a world setting). Cold LOD0-2 / whole @W12 WITHOUT passages: SW 1.12/2.25, FI 2.18/3.34, TN 2.15/3.15, VS 1.12/2.03 s - the same as with passages (FI 2.16 s). Passages are ~58% of sampled CPU but not the readiness bottleneck. A lazy exact passage-result cache was +47% slower (24% hit rate, ~700 MB) and was removed. No world change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016dhxM43dnWvUu2B5Ph1iG1
135 lines
6.2 KiB
Python
135 lines
6.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Interleaved W8/W12 cold-readiness comparison for L86 exact passage result reuse."""
|
|
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/l86/cache-scaling"
|
|
DATA = ROOT / "Standalone/data/owner_world.json"
|
|
BINARY = ROOT / "Saved/Linux/l86/bin/VoxelForgeCoreHeadless-clang19"
|
|
WORKERS = (8, 12)
|
|
MODES = ("direct", "cache")
|
|
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),
|
|
}
|
|
EXPECTED_NEAR = {0: 1408, 1: 1216, 2: 1344, 3: 1344}
|
|
EXPECTED_WHOLE = {0: 2850, 1: 2249, 2: 2233, 3: 2329}
|
|
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,
|
|
)
|
|
CACHE = re.compile(
|
|
r"^\[L86PassageResultCache\] hits=(\d+) misses=(\d+) entries=(\d+) "
|
|
r"estimated_bytes=(\d+) exact_bake_ms=([0-9.]+) bake_mode=(\S+)$", re.M)
|
|
|
|
|
|
def run(strate: int, workers: int, mode: str, phase: str, replicate: int) -> dict:
|
|
OUT.mkdir(parents=True, exist_ok=True)
|
|
label = f"s{strate}-w{workers}-{mode}-{phase}{replicate}"
|
|
log = OUT / f"{label}.log"
|
|
camera = ",".join(f"{value:.12f}" for value in CAMERAS[strate]) + ",0,0"
|
|
cache_value = "1" if mode == "cache" else "0"
|
|
command = [
|
|
"taskset", "-c", "0-11", "prlimit", "--as=6442450944", "--",
|
|
"env", "VOXELFORGE_L81_PASSAGE_BOUND_PADDING_VOXELS=0",
|
|
f"VOXELFORGE_L86_PASSAGE_RESULT_CACHE={cache_value}", "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",
|
|
]
|
|
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)
|
|
if result.returncode or pipeline_match is None or near_match is None:
|
|
raise RuntimeError(f"cache scaling run failed: exit={result.returncode} {log}")
|
|
near_done, near_total = int(near_match.group(1)), int(near_match.group(2))
|
|
if (near_done, near_total) != (EXPECTED_NEAR[strate], EXPECTED_NEAR[strate]):
|
|
raise RuntimeError(f"incomplete near set in {log}: {near_done}/{near_total}")
|
|
fields = dict(FIELDS.findall(pipeline_match.group(1)))
|
|
whole_done, whole_total = (int(value) for value in fields["whole_tiles"].split("/"))
|
|
if (whole_done, whole_total) != (EXPECTED_WHOLE[strate], EXPECTED_WHOLE[strate]):
|
|
raise RuntimeError(f"incomplete whole set in {log}: {whole_done}/{whole_total}")
|
|
cache_rows = CACHE.findall(output)
|
|
if mode == "cache" and not cache_rows:
|
|
raise RuntimeError(f"cache mode produced no cache statistics: {log}")
|
|
cache_totals = {
|
|
"hits": sum(int(row[0]) for row in cache_rows),
|
|
"misses": sum(int(row[1]) for row in cache_rows),
|
|
"entries": sum(int(row[2]) for row in cache_rows),
|
|
"estimated_bytes": sum(int(row[3]) for row in cache_rows),
|
|
"exact_bake_ms": sum(float(row[4]) for row in cache_rows),
|
|
"bake_mode": sorted({row[5] for row in cache_rows}),
|
|
}
|
|
row = {
|
|
"strate": strate, "workers": workers, "mode": mode,
|
|
"phase": phase, "replicate": replicate,
|
|
"exit_code": result.returncode, "wall_s": round(time.monotonic() - started, 3),
|
|
"lod02_ready_s": float(near_match.group(3)),
|
|
"whole_view_ready_s": float(fields["whole_view_ready"].removesuffix("s")),
|
|
"shape_s": float(fields["shape"].removesuffix("s")),
|
|
"far_shape_s": float(fields["far_shape"].removesuffix("s")),
|
|
"near_tiles": near_total, "whole_tiles": whole_total,
|
|
"cache": cache_totals, "log": str(log.relative_to(ROOT)),
|
|
}
|
|
print("[L86CacheScalingRun] " + json.dumps(row, sort_keys=True), flush=True)
|
|
return row
|
|
|
|
|
|
def main() -> int:
|
|
if not BINARY.is_file() or not DATA.is_file():
|
|
raise SystemExit(f"missing input: {BINARY} or {DATA}")
|
|
rows = []
|
|
for strate in range(4):
|
|
for workers in WORKERS:
|
|
for mode in MODES:
|
|
run(strate, workers, mode, "warmup", 0)
|
|
worker_orders = ((8, 12), (12, 8), (8, 12))
|
|
mode_orders = (("direct", "cache"), ("cache", "direct"),
|
|
("direct", "cache"))
|
|
for replicate, (worker_order, mode_order) in enumerate(
|
|
zip(worker_orders, mode_orders), 1):
|
|
for workers in worker_order:
|
|
for mode in mode_order:
|
|
rows.append(run(strate, workers, mode, "measured", replicate))
|
|
(OUT / "runs-partial.json").write_text(
|
|
json.dumps(rows, indent=2) + "\n", encoding="utf-8")
|
|
summary = []
|
|
for strate in range(4):
|
|
for workers in WORKERS:
|
|
entry = {"strate": strate, "workers": workers, "measured_runs": 3}
|
|
for mode in MODES:
|
|
subset = [row for row in rows if row["strate"] == strate
|
|
and row["workers"] == workers and row["mode"] == mode]
|
|
for metric in ("lod02_ready_s", "whole_view_ready_s", "shape_s", "far_shape_s"):
|
|
values = [row[metric] for row in subset]
|
|
entry[f"{mode}_{metric}"] = values
|
|
entry[f"{mode}_{metric}_median"] = statistics.median(values)
|
|
entry[f"{mode}_{metric}_min"] = min(values)
|
|
entry[f"{mode}_{metric}_max"] = max(values)
|
|
entry[f"{mode}_cache"] = [row["cache"] for row in subset]
|
|
summary.append(entry)
|
|
(OUT / "summary.json").write_text(
|
|
json.dumps({"runs": rows, "summary": summary}, indent=2) + "\n",
|
|
encoding="utf-8",
|
|
)
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|