Files
VoxelForge/Standalone/Research/WorldAssemblerM3/Linux76/MeasureTermProfilerOverheadL76.py
T
Fr0zkaandClaude Opus 5.5 90378a585f profile: per-term legacy FI/TN sample profiler (L76); passage/support is ~75% of field time
Opt-in at build time (VOXELFORGE_PROFILE_LEGACY_TERMS=1; compiled out by default, ~2% when on).
Per legacy sample: passage/support composer ~1.05 us vs primitive scan ~0.19 us, boundary
band ~0.06 us, noise ~0.01 us. Resolved-passage constants are cached at field binding
(arithmetic order unchanged); whole-view effect within noise. Per-tile hashes identical to L75
in all 24 compiler x worker x view comparisons; fast tier PASS; Linux UE host builds.
R40 researcher notes attached.

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

85 lines
3.5 KiB
Python

#!/usr/bin/env python3
"""Measure sampled per-term profiler overhead against the same clean candidate."""
from __future__ import annotations
import json
import os
import re
import subprocess
import time
from pathlib import Path
ROOT = Path(__file__).resolve().parents[4]
DATA = ROOT / "Standalone/data/owner_world.json"
OUT = ROOT / os.environ.get("VOXELFORGE_L76_PROFILE_OVERHEAD_OUT",
"Saved/Linux/l76/term-profiler-overhead")
BINARIES = {
"clean": ROOT / "Standalone/bin/linux/VoxelForgeCoreHeadless-l76-clang",
"profile": ROOT / "Standalone/bin/linux/VoxelForgeCoreHeadless-l76-termprofile-clang",
}
CAMERAS = {
1: (25.8369140625, 3.19921875, -737.0),
2: (19.166015625, -14.2001953125, -753.3740234375),
}
KV = re.compile(r"([a-zA-Z0-9_]+)=([^ ]+)")
def run(kind: str, strate: int, pair: int) -> dict:
OUT.mkdir(parents=True, exist_ok=True)
log = OUT / f"strate{strate}-pair{pair}-{kind}.log"
camera = ",".join(f"{value:.12f}" for value in CAMERAS[strate]) + ",0,0"
command = [
"taskset", "-c", "0-11", "prlimit", "--as=6442450944", "--", "timeout",
"1740s", str(BINARIES[kind]), str(DATA), "--world-assembler-prototype",
"--stream-benchmark", "--stream-pipeline", "--force-generate", "--workers=8",
"--clip-radius=3", "--max-clip-level=8", "--max-level=8", f"--camera={camera}",
"--profile-lod-work", "--instrument-tile-drain", "--profile-passage-composer",
]
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)
pipeline = {}
with log.open(encoding="utf-8", errors="replace") as stream:
for line in stream:
if line.startswith("[StreamPipeline]"):
pipeline = dict(KV.findall(line))
if result.returncode != 0 or "whole_view_ready" not in pipeline:
raise SystemExit(f"profiler-overhead run failed; see {log}")
return {
"kind": kind, "strate": strate, "pair": pair, "exit_code": result.returncode,
"process_wall_s": round(time.monotonic() - started, 3),
"whole_view_ready_s": float(pipeline["whole_view_ready"].removesuffix("s")),
"log": str(log.relative_to(ROOT)),
}
def main() -> int:
missing = [str(path) for path in (*BINARIES.values(), DATA) if not path.is_file()]
if missing:
raise SystemExit("missing input: " + ", ".join(missing))
rows = []
for strate in (1, 2):
for pair in range(3):
order = ("clean", "profile") if pair % 2 == 0 else ("profile", "clean")
pair_rows = {kind: run(kind, strate, pair) for kind in order}
delta = pair_rows["profile"]["whole_view_ready_s"] \
- pair_rows["clean"]["whole_view_ready_s"]
result = {
"strate": strate, "pair": pair,
"clean_s": pair_rows["clean"]["whole_view_ready_s"],
"profile_s": pair_rows["profile"]["whole_view_ready_s"],
"delta_s": round(delta, 4),
"delta_percent": round(100.0 * delta / pair_rows["clean"]["whole_view_ready_s"], 2),
"runs": [pair_rows[kind] for kind in order],
}
rows.append(result)
print("[L76TermProfilerOverhead] " + json.dumps(result, sort_keys=True), flush=True)
(OUT / "summary.json").write_text(json.dumps(rows, indent=2) + "\n", encoding="utf-8")
return 0
if __name__ == "__main__":
raise SystemExit(main())