#!/usr/bin/env python3 """Measure production-path SurfaceWorld tile work without validation hashing.""" from __future__ import annotations import argparse import json import subprocess import time from pathlib import Path ROOT = Path(__file__).resolve().parents[4] OUT = ROOT / "Saved/Linux/l71" ENGINE_OUT = OUT / "engine" HOST_PLUGIN_SAVED = Path("/home/jahni/VFHost/Plugins/VoxelForge/Saved/Linux/l71") PROJECT = Path("/home/jahni/VFHost/VFHost.uproject") EDITOR = Path("/home/jahni/UnrealEngine/Engine/Binaries/Linux/UnrealEditor-Cmd") SPAWN_M = (8.0, 16.0, -372.2626953125) def run(trial: int) -> dict: label = f"strate0-trial{trial}" traces = ENGINE_OUT / "traces" trace = traces / f"{label}.trace.jsonl" abslog = traces / f"{label}.log" stdout = traces / f"{label}.stdout.log" # VoxelForgeExplore restricts exported content to the host plugin's Saved tree. output = HOST_PLUGIN_SAVED / "output" / label userdir = ENGINE_OUT / "user" / label zendata = ENGINE_OUT / "zen" / label ddc = ENGINE_OUT / "DDC" for directory in (traces, output, userdir, zendata, ddc): directory.mkdir(parents=True, exist_ok=True) spawn_cm = ",".join(f"{value * 100.0:.3f}" for value in SPAWN_M) command = [ str(EDITOR), str(PROJECT), "-nullrhi", "-unattended", "-nop4", "-nosplash", "-NoSound", "-corelimit=12", "-NoZenAutoLaunch", "-notraceserver", "-nocrashreports", "-DisablePlugins=AndroidFileServer", "-ddc=NoZenLocalFallback", f"-userdir={userdir}", f"-ZenDataPath={zendata}", f"-LocalDataCachePath={ddc}", "-run=VoxelForgeExplore", "-seed=0", "-archetype=TunnelNetwork", "-slot=0", "-modes=export", "-gameconfig=1", "-coreworldtest=1", "-ownerfourstrateplan=1", "-corevoxelsizecm=25", "-coreislandtest=0", "-corefallbacktest=0", "-coreofftest=0", "-coreplantest=0", "-settingsref=/Game/VoxelForge/DA_Settings.DA_Settings", "-corehybridmesher=0", f"-out={output}", "-voxel.StreamingCoarseFirst=0", "-voxel.StreamingDynamicNearReserve=1", "-voxel.StreamingLegacyPendingResultCap=0", "-voxel.CoreRegionConcurrentAdmission=1", "-voxel.StreamingResultBacklogCap=256", "-voxel.StreamingReadyQueueDepth=8", "-voxel.StreamingBackgroundWorkerCap=1", "-voxel.CoreColumnCacheDirectMapped=0", "-voxel.CoreMCGradientMemoization=1", "-voxel.StreamingCollisionLookahead=1", "-coreworldstreamtrace=1", "-voxel.TestMove=0", "-voxel.TestMoveSpeedCmPerSecond=0", f"-voxel.StartupTraceSpawnCm={spawn_cm}", f"-voxel.StartupTraceFile={trace}", "-voxel.StartupTraceUntilEndPlay=1", "-voxel.StartupTraceMaxTiles=16384", "-voxel.CollisionGate=0", f"-abslog={abslog}", ] started = time.monotonic() with stdout.open("w", encoding="utf-8") as stream: # UE itself is CPU-pinned and time-bounded. Linux does not enforce --rss. result = subprocess.run( ["taskset", "-c", "0-11", "timeout", "1740s", *command], cwd=ROOT, stdout=stream, stderr=subprocess.STDOUT, check=False, timeout=1740, ) elapsed = time.monotonic() - started events = set() if trace.is_file(): for line in trace.read_text(encoding="utf-8", errors="replace").splitlines(): try: events.add(json.loads(line).get("type", "")) except json.JSONDecodeError: continue row = { "label": label, "trial": trial, "spawn_m": SPAWN_M, "elapsed_s": round(elapsed, 3), "exit_code": result.returncode, "trace": str(trace), "stdout": str(stdout), "events": sorted(events), "has_walkable_gate": "walkable_gate" in events, "has_lod0_ring": "lod0_ring_ready" in events, "has_initial_set": "stream_trace_milestone" in events, "has_summary": "summary" in events, } print(f"[L71EngineTrace] {json.dumps(row, sort_keys=True)}", flush=True) return row def main() -> int: parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--trials", type=int, default=3, choices=range(1, 4)) args = parser.parse_args() if not EDITOR.is_file() or not PROJECT.is_file(): raise SystemExit(f"missing UnrealEditor-Cmd or host project: {EDITOR} {PROJECT}") rows = [run(trial) for trial in range(1, args.trials + 1)] summary = ENGINE_OUT / "surface-trace-summary.json" summary.write_text(json.dumps(rows, indent=2) + "\n", encoding="utf-8") complete = all(row["exit_code"] == 0 and row["has_walkable_gate"] and row["has_lod0_ring"] and row["has_initial_set"] and row["has_summary"] for row in rows) print(f"[L71EngineTraceSet] trials={len(rows)} status={'PASS' if complete else 'INCOMPLETE'} " f"summary={summary}", flush=True) return 0 if complete else 2 if __name__ == "__main__": raise SystemExit(main())