L86's switch left ApplyResolvedStratePassageCarves running (near-tile service unchanged at ~21 worker-s), so its "no change" ceiling was wrong. Corrected (bands + carves off): FI LOD0-2 2.34 -> 0.66 s, whole 3.47 -> 1.49 s @W12; TN 2.27 -> 0.74 / 3.28 -> 1.52 s. Near-tile service 15.6-22.5 -> 2.6-3.8 worker-s. Critical chain: shape/base compile -> LOD0-1 -> far-parent build (107-153 ms, pipeline thread) -> LOD2. Workers 81-85% busy in the direct window. No production scheduling change; hashes equal L85. Fast tier PASS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016dhxM43dnWvUu2B5Ph1iG1
188 lines
8.8 KiB
Python
188 lines
8.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Interleaved L87 passage A/B readiness and worker timeline matrix."""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import argparse
|
|
import re
|
|
import statistics
|
|
import subprocess
|
|
import time
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[4]
|
|
OUT = ROOT / "Saved/Linux/l87/timeline/switch-fixed"
|
|
DATA = ROOT / "Standalone/data/owner_world.json"
|
|
BINARY = ROOT / "Saved/Linux/l87/bin/VoxelForgeCoreHeadless-clang19"
|
|
SOURCE_STAMP = "ac3d8ea64e9ac4bd5526c61990070fb504528ff56dae52d33c1937327374032b"
|
|
STRATA = {
|
|
"FI": {"id": 1, "camera": (25.8369140625, 3.19921875, -737.0),
|
|
"near": 1216, "whole": 2249},
|
|
"TN": {"id": 2, "camera": (19.166015625, -14.2001953125, -753.3740234375),
|
|
"near": 1344, "whole": 2233},
|
|
}
|
|
WORKERS = (8, 12)
|
|
MODES = ("direct", "passage_off")
|
|
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,
|
|
)
|
|
PUBLISHED = re.compile(
|
|
r"^\[WorldAssemblerNearLODPublished\] lods=0-2 tiles=(\d+)/(\d+) cold_ready_s=([0-9.]+)$",
|
|
re.M,
|
|
)
|
|
PIPELINE_READY = re.compile(
|
|
r"^\[WorldAssemblerNearLODPipelineReady\] lods=0-2 tiles=(\d+)/(\d+) cold_ready_s=([0-9.]+)$",
|
|
re.M,
|
|
)
|
|
SHAPE = re.compile(
|
|
r"^\[FarShapeStage\] parent_shapes=([0-9.]+) ms spatial_bins=([0-9.]+) ms total=([0-9.]+) ms",
|
|
re.M,
|
|
)
|
|
CONFIG = re.compile(r"^\[HeadlessConfig\] (.*)$", re.M)
|
|
STAMP = re.compile(r"^\[VoxelForgeSourceStamp\] sha256=(\S+)$", re.M)
|
|
VOLUME = re.compile(r"^\[PipelineVolume\] tiles=(\d+) lod=", re.M)
|
|
TIMELINE_EVENTS = re.compile(r"^\[CpuTileTimeline\] event=(\S+)", re.M)
|
|
|
|
|
|
def command(stratum: str, workers: int, mode: str, timeline: bool) -> list[str]:
|
|
camera = ",".join(f"{v:.12f}" for v in STRATA[stratum]["camera"]) + ",0,0"
|
|
child = [
|
|
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",
|
|
]
|
|
if timeline:
|
|
child.append("--cold-worker-timeline")
|
|
env = ["VOXELFORGE_L81_PASSAGE_BOUND_PADDING_VOXELS=0"]
|
|
if mode == "passage_off":
|
|
env.append("VOXELFORGE_L86_DISABLE_PASSAGE_COMPOSITION=1")
|
|
return [
|
|
"taskset", "-c", "0-11", "prlimit", "--as=6442450944", "--", "env",
|
|
*env, "timeout", "1740s", *child,
|
|
]
|
|
|
|
|
|
def run(stratum: str, workers: int, mode: str, phase: str,
|
|
replicate: int, timeline: bool) -> dict:
|
|
OUT.mkdir(parents=True, exist_ok=True)
|
|
rep = f"-r{replicate}" if phase == "measured" else ""
|
|
label = f"{stratum.lower()}-w{workers}-{mode}-{phase}{rep}"
|
|
log = OUT / f"{label}.log"
|
|
started = time.monotonic()
|
|
with log.open("w", encoding="utf-8") as output:
|
|
result = subprocess.run(command(stratum, workers, mode, timeline), cwd=ROOT,
|
|
stdout=output, stderr=subprocess.STDOUT,
|
|
check=False, timeout=1740)
|
|
content = log.read_text(encoding="utf-8", errors="replace")
|
|
near, published, pipeline_ready = (
|
|
NEAR.search(content), PUBLISHED.search(content), PIPELINE_READY.search(content)
|
|
)
|
|
pipeline_match, far = PIPELINE.search(content), SHAPE.search(content)
|
|
stamp_match = STAMP.search(content)
|
|
config_match, volume_match = CONFIG.search(content), VOLUME.search(content)
|
|
if result.returncode or not all((near, published, pipeline_ready, pipeline_match, far,
|
|
config_match, volume_match, stamp_match)):
|
|
raise RuntimeError(f"run failed or required timeline is missing: {log}; exit={result.returncode}")
|
|
if stamp_match.group(1) != SOURCE_STAMP:
|
|
raise RuntimeError(f"source stamp mismatch in {log}: {stamp_match.group(1)}")
|
|
expected = STRATA[stratum]
|
|
config_fields = dict(FIELDS.findall(config_match.group(1)))
|
|
if int(config_fields["workers"]) != workers:
|
|
raise RuntimeError(f"worker mismatch in {log}: {config_fields['workers']}")
|
|
if int(volume_match.group(1)) != expected["whole"]:
|
|
raise RuntimeError(f"wrong camera/strate window in {log}: {volume_match.group(1)} tiles")
|
|
if ("[L86PassageCeiling]" in content) != (mode == "passage_off"):
|
|
raise RuntimeError(f"passage switch state mismatch in {log}")
|
|
for match in (near, published, pipeline_ready):
|
|
if (int(match.group(1)), int(match.group(2))) != (expected["near"], expected["near"]):
|
|
raise RuntimeError(f"incomplete near set in {log}: {match.group(1)}/{match.group(2)}")
|
|
fields = dict(FIELDS.findall(pipeline_match.group(1)))
|
|
whole_done, whole_total = (int(v) for v in fields["whole_tiles"].split("/"))
|
|
if (whole_done, whole_total) != (expected["whole"], expected["whole"]):
|
|
raise RuntimeError(f"incomplete whole view in {log}: {whole_done}/{whole_total}")
|
|
cpu_events = TIMELINE_EVENTS.findall(content)
|
|
if timeline and not cpu_events:
|
|
raise RuntimeError(f"worker timeline missing in {log}")
|
|
row = {
|
|
"stratum": stratum, "stratum_id": expected["id"], "workers": workers,
|
|
"mode": mode, "phase": phase, "replicate": replicate,
|
|
"timeline": timeline, "headless_recipe_label": config_fields.get("recipe"),
|
|
"cpu_tile_timeline_events": len(cpu_events),
|
|
"exit_code": result.returncode, "wall_s": round(time.monotonic() - started, 3),
|
|
"source_stamp": stamp_match.group(1),
|
|
"lod02_ready_s": float(near.group(3)),
|
|
"lod02_published_s": float(published.group(3)),
|
|
"lod02_pipeline_ready_s": float(pipeline_ready.group(3)),
|
|
"whole_view_ready_s": float(fields["whole_view_ready"].removesuffix("s")),
|
|
"shape_s": float(fields["shape"].removesuffix("s")),
|
|
"far_shape_s": float(far.group(3)) / 1000.0,
|
|
"far_parent_ms": float(far.group(1)), "far_bins_ms": float(far.group(2)),
|
|
"near_tiles": expected["near"], "whole_tiles": expected["whole"],
|
|
"log": str(log.relative_to(ROOT)),
|
|
}
|
|
print("[L87TimelineRun] " + json.dumps(row, sort_keys=True), flush=True)
|
|
return row
|
|
|
|
|
|
def main() -> int:
|
|
global OUT
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--out", type=Path, default=Path("Saved/Linux/l87/timeline/final-phase"))
|
|
args = parser.parse_args()
|
|
OUT = args.out if args.out.is_absolute() else ROOT / args.out
|
|
if not BINARY.is_file() or not DATA.is_file():
|
|
raise SystemExit(f"missing input: {BINARY} or {DATA}")
|
|
# L80 warmup: once per camera window and worker count. Rotate both mode and
|
|
# worker order across three paired measured replicates.
|
|
for stratum in STRATA:
|
|
for workers in WORKERS:
|
|
for mode in MODES:
|
|
run(stratum, workers, mode, "warmup", 0, False)
|
|
|
|
measured = []
|
|
orders = (
|
|
((8, "direct"), (8, "passage_off"), (12, "passage_off"), (12, "direct")),
|
|
((12, "direct"), (12, "passage_off"), (8, "passage_off"), (8, "direct")),
|
|
((8, "passage_off"), (8, "direct"), (12, "direct"), (12, "passage_off")),
|
|
)
|
|
for stratum in STRATA:
|
|
timeline_pending = {(workers, mode) for workers in WORKERS for mode in MODES}
|
|
for replicate, order in enumerate(orders, 1):
|
|
for workers, mode in order:
|
|
timeline = (workers, mode) in timeline_pending
|
|
if timeline:
|
|
timeline_pending.remove((workers, mode))
|
|
measured.append(run(stratum, workers, mode, "measured", replicate, timeline))
|
|
(OUT / "runs-partial.json").write_text(
|
|
json.dumps(measured, indent=2) + "\n", encoding="utf-8")
|
|
|
|
summary = []
|
|
for stratum in STRATA:
|
|
for workers in WORKERS:
|
|
for mode in MODES:
|
|
rows = [row for row in measured if row["stratum"] == stratum
|
|
and row["workers"] == workers and row["mode"] == mode]
|
|
if len(rows) != 3:
|
|
raise RuntimeError(f"expected 3 measured replicates for {stratum} W{workers} {mode}")
|
|
item = {"stratum": stratum, "workers": workers, "mode": mode,
|
|
"measured_runs": 3}
|
|
for metric in ("lod02_ready_s", "lod02_published_s",
|
|
"lod02_pipeline_ready_s", "whole_view_ready_s",
|
|
"shape_s", "far_shape_s"):
|
|
values = [row[metric] for row in rows]
|
|
item[metric] = values
|
|
item[f"{metric}_median"] = statistics.median(values)
|
|
summary.append(item)
|
|
(OUT / "summary.json").write_text(
|
|
json.dumps({"runs": measured, "summary": summary}, indent=2) + "\n",
|
|
encoding="utf-8")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|