#!/usr/bin/env python3 """One Unreal null-RHI streaming trace starting in the FI stratum.""" from __future__ import annotations import json import re import subprocess import time from pathlib import Path ROOT = Path(__file__).resolve().parents[4] HOST = Path("/home/jahni/VFHost") EDITOR = Path("/home/jahni/UnrealEngine/Engine/Binaries/Linux/UnrealEditor-Cmd") OUT = ROOT / "Saved/Linux/l85/unreal-fi" HOST_PLUGIN_SAVED = HOST / "Plugins/VoxelForge/Saved/Linux/l85" HOST_SAVED = HOST / "Saved/Linux/l85" SPAWN_M = (25.8369140625, 3.19921875, -737.0) SAMPLE_SECONDS = 0.25 MOVE_START_S = 6.0 MOVE_DURATION_S = 12.0 DWELL_S = 5.0 EXIT_S = MOVE_START_S + MOVE_DURATION_S + DWELL_S def main() -> int: if not EDITOR.is_file(): raise SystemExit(f"missing Unreal commandlet executable: {EDITOR}") label = "fi-arrival-l85" trace = OUT / f"{label}.trace.jsonl" abslog = OUT / f"{label}.log" stdout = OUT / f"{label}.stdout.log" output = HOST_PLUGIN_SAVED / "output" / label userdir = HOST_SAVED / "user" / label zendata = HOST_SAVED / "zen" / label ddc = HOST_SAVED / "DDC" for directory in (OUT, 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(HOST / "VFHost.uproject"), "-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=1", "-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=1", "-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", "-voxel.TestMove=1", "-voxel.TestMoveSpeedCmPerSecond=140.0", f"-voxel.TestMoveStartSeconds={MOVE_START_S:.1f}", f"-voxel.TestMoveDurationSeconds={MOVE_DURATION_S:.1f}", f"-voxel.TestExitSeconds={EXIT_S:.1f}", "-voxel.TestMoveDirection=1,0,0", "-voxel.StreamingSchedulerPolicy=3", "-voxel.TestExitOnSteady=0", "-coreworldstreamtrace=1", f"-voxel.StartupTraceSpawnCm={spawn_cm}", "-voxel.StartupTraceUntilEndPlay=1", "-voxel.StartupTraceThroughCrossing=1", "-voxel.StartupTraceMaxTiles=16384", f"-voxel.StartupTraceFile={trace}", f"-abslog={abslog}", ] wrapped = ["taskset", "-c", "0-11", "timeout", "1740s", *command] started = time.monotonic() OUT.mkdir(parents=True, exist_ok=True) with stdout.open("w", encoding="utf-8") as stream: result = subprocess.run(wrapped, cwd=ROOT, stdout=stream, stderr=subprocess.STDOUT, check=False, timeout=1740) events = [] if trace.is_file(): for line in trace.read_text(encoding="utf-8", errors="replace").splitlines(): if line.startswith("{"): try: events.append(json.loads(line)) except json.JSONDecodeError: pass samples = [event for event in events if event.get("type") == "streaming_sample"] arrival = [event for event in samples if float(event.get("t_s", 0.0)) < MOVE_START_S] full = [] for event in arrival: desired = sum(event.get("desired_by_lod", [0] * 9)[:3]) resident = sum(event.get("resident_by_lod", [0] * 9)[:3]) if desired and resident >= desired: full.append(event) break row = { "label": label, "exit_code": result.returncode, "wall_s": round(time.monotonic() - started, 3), "sample_count": len(samples), "arrival_sample_count": len(arrival), "first_lod02_full_ready_s": full[0]["t_s"] if full else None, "first_lod02_full_desired": (sum(full[0].get("desired_by_lod", [0] * 9)[:3]) if full else None), "first_lod02_full_resident": (sum(full[0].get("resident_by_lod", [0] * 9)[:3]) if full else None), "trace": str(trace.relative_to(ROOT)), "abslog": str(abslog.relative_to(ROOT)), "stdout": str(stdout.relative_to(ROOT)), } failure = re.search(r"\[VoxelForgeCoreWorldTest\] failed: ([^\r\n]+)", stdout.read_text(encoding="utf-8", errors="replace")) if failure: row["world_test_failure"] = failure.group(1) (OUT / "summary.json").write_text(json.dumps(row, indent=2) + "\n", encoding="utf-8") print("[L85UnrealFITrace] " + json.dumps(row, sort_keys=True), flush=True) if result.returncode or len(samples) < 40: raise SystemExit("Unreal FI trace did not complete successfully") return 0 if __name__ == "__main__": raise SystemExit(main())