diff --git a/Standalone/Core/src/ShapeWorldInternal.h b/Standalone/Core/src/ShapeWorldInternal.h index 1d361e5..855a6ab 100644 --- a/Standalone/Core/src/ShapeWorldInternal.h +++ b/Standalone/Core/src/ShapeWorldInternal.h @@ -333,10 +333,13 @@ public: candidate.maximumSubvoxels=bounds.maximumSubvoxels; candidate.sweepMinimumSubvoxels=bounds.minimumSubvoxels; candidate.sweepMaximumSubvoxels=bounds.maximumSubvoxels; + if(passageRoutes_[feature.passageIndex]==0) + routePassageIndices_.push_back(feature.passageIndex); passageRoutes_[feature.passageIndex]=1; passageRouteSegments_[feature.passageIndex].push_back(candidate); ++routeSegmentCandidateCount_; } + std::sort(routePassageIndices_.begin(),routePassageIndices_.end()); for(auto& candidates:passageRouteSegments_) { std::sort(candidates.begin(),candidates.end(),[](const auto& a,const auto& b) @@ -352,6 +355,7 @@ public: maximumSubvoxels_(source.maximumSubvoxels_),featureIndices_(source.featureIndices_), stampIndices_(source.stampIndices_),cavernFeatureIndices_(source.cavernFeatureIndices_), passageRoutes_(source.passageRoutes_), + routePassageIndices_(source.routePassageIndices_), passageRouteSegments_(source.passageRouteSegments_), previous_(ActivePassageTileQueries),profileStats_(source.profileStats_), profileLod_(source.profileLod_), @@ -463,6 +467,8 @@ public: } bool hasRouteFeature(std::size_t passageIndex) const {return passageIndex& routePassageIndices() const noexcept + {return routePassageIndices_;} bool routeFeatureMayAffect(std::size_t passageIndex,double qx,double qy, double qz) const { @@ -502,6 +508,7 @@ public: std::array minimumSubvoxels_,maximumSubvoxels_; std::vector featureIndices_,stampIndices_,cavernFeatureIndices_; std::vector passageRoutes_; + std::vector routePassageIndices_; std::vector> passageRouteSegments_; std::size_t routeSegmentCandidateCount_=0; bool mayContainResolvedBoundaryBand_=true,mayContainTransitionPassageFade_=true; @@ -1199,6 +1206,21 @@ public: VoxelForgeCore::Linux77Profiler::EPhase::Passage); if(!ResolvedLayout||ResolvedLayout->passages.empty()||!std::isfinite(X) ||!std::isfinite(Y)||!std::isfinite(Z))return density; + const auto* passageTileQueries=ActivePassageTileQueries; + const bool passageTileScopeMatches=passageTileQueries + &&passageTileQueries->matches(*this); + auto* passageProfile=passageTileScopeMatches + ?passageTileQueries->profileStats():nullptr; + if(passageProfile)++passageProfile->passageComposerQueries; + if(passageProfile&&nativeTunnelFieldDensity + !=std::numeric_limits::lowest()) + ++passageProfile->nativeCaveFieldSamples; + // The tile feature list is a conservative broad phase. If no passage route + // can affect this tile, none of the per-sample mouth, shell, or relief work + // below can change the field. + if(passageTileScopeMatches + &&passageTileQueries->routePassageIndices().empty())return density; + constexpr double Q=static_cast(VoxelForgeCore::WorldAssemblySubvoxelsPerVoxel); constexpr double FloorShellThicknessMetres=VF_PassageShellThicknessMetres; constexpr double WallReliefMetres=VF_PassageWallReliefMetres; @@ -1209,16 +1231,6 @@ public: const double qx=static_cast(X)*Q,qy=static_cast(Y)*Q, qz=static_cast(Z)*Q; const double shellThickness=FloorShellThicknessMetres*qPerMetre; - const auto* passageTileQueries=ActivePassageTileQueries; - const bool passageTileScopeMatches=passageTileQueries - &&passageTileQueries->matches(*this); - auto* passageProfile=passageTileScopeMatches - ?passageTileQueries->profileStats():nullptr; - if(passageProfile)++passageProfile->passageComposerQueries; - if(passageProfile&&nativeTunnelFieldDensity - !=std::numeric_limits::lowest()) - ++passageProfile->nativeCaveFieldSamples; - struct FNearestTubeSample { double signedDistance=std::numeric_limits::infinity(); @@ -1241,9 +1253,14 @@ public: &&queryStratum->Resolved->generatorKind=="TunnelNetwork" &&queryStratum->Resolved->recipeId=="Core.Caves.PrimitiveField" &&queryStratum->Resolved->recipeVersion==1; - for(std::size_t passageIndex=0;passageIndexpassages.size(); - ++passageIndex) + const auto* routePassageIndices=passageTileScopeMatches + ?&passageTileQueries->routePassageIndices():nullptr; + const std::size_t routeCount=passageTileScopeMatches + ?routePassageIndices->size():ResolvedLayout->passages.size(); + for(std::size_t routeOffset=0;routeOffsetpassages[passageIndex]; if(passage.controlPoints.size()<2)continue; const bool surfaceDepartureLanding=queryStratum&&queryStratum->Resolved @@ -1275,8 +1292,6 @@ public: if(passageTargetsNativeCaveField&&!passageTargetsPlannedTunnelNetwork) continue; if(passageProfile)++passageProfile->passageIterations; - if(passageTileScopeMatches&&!passageTileQueries->hasRouteFeature(passageIndex)) - continue; const auto& constants=PassageComposerConstants[passageIndex]; FNearestTubeSample nearest; @@ -7767,8 +7782,6 @@ private: *nativeFloorSupport=std::numeric_limits::lowest(); (void)density; const double metresPerVoxel=Owner->CoreVoxelSizeMicrons/1000000.0; - const std::array point={X*metresPerVoxel,Y*metresPerVoxel, - Z*metresPerVoxel}; std::vector localCandidates; const std::vector* candidates=nullptr; if(scoped)candidates=&tileQueries->cavernFeatureCandidates(); @@ -7782,6 +7795,14 @@ private: localCandidates=BuildCavernFeatureTileList(coordinate,coordinate); candidates=&localCandidates; } + // No cave feature overlaps this scoped tile (or unscoped point), so the + // native field is exactly its constant host-rock value. Avoid per-sample + // coordinate conversion and the empty feature-composition path. + constexpr double HostRockMetres=-32.0; + if(candidates->empty()) + return static_cast(HostRockMetres/metresPerVoxel); + const std::array point={X*metresPerVoxel,Y*metresPerVoxel, + Z*metresPerVoxel}; double caveVoid=std::numeric_limits::infinity(); double nativeFloorSupportMinimum=std::numeric_limits::infinity(); double floorSupportScore=std::numeric_limits::infinity(); @@ -8024,7 +8045,6 @@ private: // resolved interval oracle uses the same finite -32 m solid value; using // the underlying legacy generator density here would leak its unrelated // terrain detail into the cave floor and invalidate those proofs. - constexpr double HostRockMetres=-32.0; const double hostDistance=HostRockMetres; double composed=std::isfinite(caveVoid) ?SmoothMaxMetres(hostDistance,-caveVoid,0.0):hostDistance; diff --git a/Standalone/Research/WorldAssemblerM3/Linux136/REPORT.md b/Standalone/Research/WorldAssemblerM3/Linux136/REPORT.md new file mode 100644 index 0000000..a7a61bd --- /dev/null +++ b/Standalone/Research/WorldAssemblerM3/Linux136/REPORT.md @@ -0,0 +1,33 @@ +# Linux136 — cave planner speed + +Source stamp `ebe6b32a7cd96c5aa69c6dc64ae6b9c6ff4bc18bc484efc5148611c48723c28f` (v239; v236 is commit `2d89023`). + +## Findings + +The tile query now keeps sorted passage IDs with route candidates, so the composer skips unrelated routes. A route-free tile returns before per-sample coordinate and scale math. Native cave evaluation also returns the exact host-rock value when its conservative tile feature list is empty. These paths preserve v236 output; no version bump was needed. + +The LOD0–2 census shows the shared composer does substantial work outside Tunnel Network. Surface World has zero native cave samples at LOD0–3, yet near-ready passage visits are 19.61M on both `assembler/world` and v236. The route-ID path reduces that count to 3.20M, but cumulative near-ready composer worker time stays around 3.5 s (3.42 s baseline, 3.51 s v236, 3.52 s v239). Whole-view classification worker time is 584 ms / 641 ms / 623 ms. Planning is about 4 ms. This rules out cave evaluation and planning as the Surface World regression, but the census does not isolate mouth-profile checks from the other shared composer/classifier work. + +Floating Islands and Vertical Shafts have unrelated-route churn: v236 adds 7.79M and 8.43M passage visits over baseline. v239 brings those totals to 7.89M and 2.54M, and reduces composer worker time by about 9% and 8% versus v236. Tunnel Network falls from 34.63M visits in v236 to 7.47M; its composer worker time returns to baseline. The views still process about 4.7–5.4M native cave samples. The attempted LOD4–8 cave tile proofs produced no skips: every cave-view tile at those LODs remained unclassified. + +## L80 timing + +Five interleaved measured runs per version and cell, one warmup per version. The pre-run gate was load 0.74 and 99.3% CPU idle. Cells show near-ready and whole-view median deltas versus `assembler/world`, in W8/W12 order; the last column shows near-ready deltas versus v236. + +| Stratum | Near-ready Δ | Whole-view Δ | Near-ready Δ vs v236 | +|---|---:|---:|---:| +| Surface World (0) | +4.29% / +5.78% | +2.45% / −0.17% | +0.52% / −1.99% | +| Floating Islands (1) | +8.88% / +5.48% | +1.31% / −0.48% | −2.40% / −4.29% | +| Tunnel Network (2) | +8.23% / +8.26% | +0.35% / +0.88% | −3.51% / −3.97% | +| Vertical Shafts (3) | +13.29% / +6.36% | +1.26% / −1.97% | −4.22% / −3.81% | + +v239 improves on v236 in seven of eight near-ready cells, but misses the requested ≤+3% target in all eight cells versus `assembler/world`. Whole-view deltas stay within +2.45%/−1.97%. + +## Gates + +- Fast tier: PASS, 289.9 s. +- Composed passage, seam, shell, mouth, ripple, naturalness, and blocked-route audits: 16/16 seeds PASS. +- Clang and GCC at W1/W8/W12: all six runs match 13 hash lines. +- Linux VFHostEditor Development: PASS, 5/5 actions in 41.33 s with `-NoUBA -MaxParallelActions=4`; no `prlimit`. + +Timing, census, seed, determinism, and build logs are under `Saved/Linux/l136/`. The completed timing matrix is `Saved/Linux/l136/timing/summary.json`; the interrupted partial matrix is excluded. No commit or push was made. diff --git a/Standalone/Research/WorldAssemblerM3/Linux136/RunL136Census.py b/Standalone/Research/WorldAssemblerM3/Linux136/RunL136Census.py new file mode 100644 index 0000000..dd0ab23 --- /dev/null +++ b/Standalone/Research/WorldAssemblerM3/Linux136/RunL136Census.py @@ -0,0 +1,113 @@ +#!/usr/bin/env python3 +"""Compare assembler/world and v236 composer/classifier phase counters.""" +from __future__ import annotations + +import json +import re +import subprocess +import time +from collections import defaultdict +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[4] +OUT = ROOT / "Saved/Linux/l136/census" +DATA = ROOT / "Standalone/data/owner_world.json" +BINARIES = { + "assembler-world": ROOT / "Saved/Linux/l130/bin/VoxelForgeCoreHeadless-l130-clang", + "v236": ROOT / "Saved/Linux/l135/bin/VoxelForgeCoreHeadless-clang-l135", + "v239": ROOT / "Saved/Linux/l136/bin/VoxelForgeCoreHeadless-l136-clang", +} +STAMPS = { + "assembler-world": "8b3e7bfb4cde2b408ab940925eab973d8375d6b719774d6f72f64ee72b526c35", + "v236": "8dc4294ce0250a591ee4515471c3c547e796ffa4346ab44f0ae1740bbc3797f5", + "v239": "ebe6b32a7cd96c5aa69c6dc64ae6b9c6ff4bc18bc484efc5148611c48723c28f", +} +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), +} +FIELDS = re.compile(r"([a-zA-Z0-9_]+)=([^ ]+)") + + +def field(line: str) -> dict[str, str]: + return dict(FIELDS.findall(line)) + + +def run(strate: int, version: str) -> dict: + OUT.mkdir(parents=True, exist_ok=True) + log = OUT / f"{version}-s{strate}.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[version]), str(DATA), + "--world-assembler-prototype", "--stream-benchmark", "--stream-pipeline", + "--workers=8", "--clip-radius=3", "--max-clip-level=8", "--max-level=8", + f"--camera={camera}", "--profile-lod-work", "--profile-passage-composer", + "--stream-scheduler-policy=3"] + 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) + content = log.read_text(encoding="utf-8", errors="replace") + stamp_match = re.search(r"^\[VoxelForgeSourceStamp\] sha256=([0-9a-f]+)$", content, re.M) + if result.returncode or stamp_match is None or stamp_match.group(1) != STAMPS[version]: + raise SystemExit(f"census failed/stamp mismatch: {log}, exit={result.returncode}, stamp={stamp_match}") + lod: dict[int, dict] = defaultdict(lambda: defaultdict(float)) + for line in content.splitlines(): + if line.startswith("[WorldAssemblerLODClassification] "): + values = field(line) + target = lod[int(values["lod"])] + for name in ("tiles", "all_air", "all_solid", "mixed", "unclassified", + "tile_skips", "density_point_calls", "field_eval_sample_points", + "proof_air_cells", "proof_solid_cells"): + target[name] = int(values.get(name, "0")) + target["field_eval_ms_est"] = float(values.get("field_eval_ms_est", "0")) + elif line.startswith("[PassageComposerTile] "): + values = field(line) + level = int(re.search(r"lod(\d+)\)", values["key"]).group(1)) + target = lod[level] + target["composer_tiles"] += 1 + for name in ("samples", "field_calls", "native_cave_samples", "native_field_calls", + "room_candidates", "edge_candidates", "features", "route_candidates", + "passage_iterations", "carve_segment_visits"): + target[name] += int(values.get(name, "0")) + target["composer_worker_ms"] += float(values.get("worker_ms", "0")) + plan = re.search(r"^\[WorldAssemblerPlanTiming\] total_ms=([0-9.]+)", content, re.M) + cave = re.search(r"^\[CavernPlannerV1\].* plan_ms=([0-9.]+)", content, re.M) + pipeline = re.search(r"^\[WorldAssemblerTilePipeline\] (.*)$", content, re.M) + pipeline_fields = field(pipeline.group(1)) if pipeline else {} + result_row = { + "strate": strate, "version": version, "source_stamp": stamp_match.group(1), + "plan_ms": float(plan.group(1)) if plan else None, + "cave_plan_ms": float(cave.group(1)) if cave else None, + "tile_pipeline": {key: (float(value) if "." in value else int(value)) + for key, value in pipeline_fields.items() + if re.fullmatch(r"-?\d+(?:\.\d+)?", value)}, + "lod": {str(key): dict(values) for key, values in sorted(lod.items())}, + "wall_s": round(time.monotonic() - started, 3), + "log": str(log.relative_to(ROOT)), + } + print("[L136CensusRun] " + json.dumps(result_row, sort_keys=True), flush=True) + return result_row + + +def main() -> int: + if any(not path.is_file() for path in (DATA, *BINARIES.values())): + raise SystemExit("missing census fixture or binary") + rows = [] + for strate in range(4): + for version in BINARIES: + rows.append(run(strate, version)) + (OUT / "runs-partial.json").write_text(json.dumps(rows, indent=2) + "\n") + summary = {"status": "PASS", "rows": rows, + "notes": [ + "classifier milliseconds and composer worker milliseconds are cumulative counters, not exclusive wall time", + "assembler/world predates native cave field counters; field sample fields are only comparable where emitted", + ]} + (OUT / "summary.json").write_text(json.dumps(summary, indent=2) + "\n") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/Standalone/Research/WorldAssemblerM3/Linux136/RunL136Determinism.py b/Standalone/Research/WorldAssemblerM3/Linux136/RunL136Determinism.py new file mode 100644 index 0000000..ec87f62 --- /dev/null +++ b/Standalone/Research/WorldAssemblerM3/Linux136/RunL136Determinism.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python3 +"""Check exact-stamp Clang/GCC cave-path hashes at 1, 8, and 12 workers.""" +from __future__ import annotations + +import json +import re +import subprocess +import time +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[4] +OUT = ROOT / "Saved/Linux/l136/determinism" +DATA = ROOT / "Standalone/data/regression/owner_world_2strate_l61.json" +BINARIES = { + "clang": ROOT / "Saved/Linux/l136/fast/bin/VoxelForgeCoreHeadless-fast-clang", + "gcc": ROOT / "Saved/Linux/l136/fast/bin/VoxelForgeCoreHeadless-fast-gcc", +} +STAMP = "ebe6b32a7cd96c5aa69c6dc64ae6b9c6ff4bc18bc484efc5148611c48723c28f" +CAMERA = "-4.688214,38.662384,-505.781342,-28.446,0" +HASH_RE = re.compile( + r"^\[Pipeline(?:FullDetailHash|WholeViewHash|MaterialHash|LODHash|ExactQueryHash)\].*$", + re.M) +STAMP_RE = re.compile(r"^\[VoxelForgeSourceStamp\] sha256=([0-9a-f]+)$", re.M) + + +def main() -> int: + if any(not path.is_file() for path in (DATA, *BINARIES.values())): + raise SystemExit("missing L136 determinism binary or owner fixture") + OUT.mkdir(parents=True, exist_ok=True) + rows = [] + baseline: tuple[str, ...] | None = None + for compiler, binary in BINARIES.items(): + for workers in (1, 8, 12): + label = f"determinism-{compiler}-w{workers}" + log = OUT / f"{label}.log" + command = ["taskset", "-c", "0-11", "prlimit", "--as=6442450944", "--", + "timeout", "1740s", str(binary), str(DATA), + "--world-assembler-prototype", "--stream-benchmark", "--stream-pipeline", + f"--workers={workers}", "--clip-radius=3", "--max-clip-level=0", + "--max-level=0", f"--camera={CAMERA}", "--stream-hash-tiles", + "--force-generate", "--recipe=surface-world", "--render-distance-chunks=0", + "--landmark-chamber-demo", "--ore-veins-demo"] + 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) + content = log.read_text(encoding="utf-8", errors="replace") + found_stamp = STAMP_RE.search(content) + hashes = tuple(HASH_RE.findall(content)) + passed = (result.returncode == 0 and found_stamp is not None + and found_stamp.group(1) == STAMP and len(hashes) >= 4) + if baseline is None and passed: + baseline = hashes + elif baseline is not None: + passed &= hashes == baseline + row = {"compiler": compiler, "workers": workers, + "exit": result.returncode, "stamp": found_stamp.group(1) + if found_stamp else None, + "hash_lines": len(hashes), "hashes_match_first": hashes == baseline, + "passed": bool(passed), "elapsed_s": round(time.monotonic() - started, 3), + "log": str(log.relative_to(ROOT))} + rows.append(row) + print("[L136DeterminismRun] " + json.dumps(row, sort_keys=True), flush=True) + if not passed: + (OUT / "summary.json").write_text(json.dumps( + {"status": "FAIL", "stamp": STAMP, "runs": rows}, indent=2) + "\n") + raise SystemExit(f"determinism mismatch; see {log}") + (OUT / "summary.json").write_text(json.dumps( + {"status": "PASS", "stamp": STAMP, "runs": rows}, indent=2) + "\n") + print(f"[L136DeterminismSummary] runs={len(rows)} stamp={STAMP} status=PASS") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/Standalone/Research/WorldAssemblerM3/Linux136/RunL136SeedSweep.py b/Standalone/Research/WorldAssemblerM3/Linux136/RunL136SeedSweep.py new file mode 100644 index 0000000..aa8ca80 --- /dev/null +++ b/Standalone/Research/WorldAssemblerM3/Linux136/RunL136SeedSweep.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python3 +"""Run the v239 composed cave-passage and tile-seam audits for fixed seeds.""" +from __future__ import annotations + +import json +import re +import subprocess +import sys +import time +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[4] +OUT = ROOT / "Saved/Linux/l136/seeds" +BIN = ROOT / "Saved/Linux/l136/bin/VoxelForgeCoreHeadless-l136-clang" +DATA = ROOT / "Standalone/data/owner_world.json" +STAMP = "ebe6b32a7cd96c5aa69c6dc64ae6b9c6ff4bc18bc484efc5148611c48723c28f" +STAMP_RE = re.compile(r"^\[VoxelForgeSourceStamp\] sha256=([0-9a-f]+)$", re.M) +REQUIRED = { + "passage": re.compile(r"^\[ResolvedPassageAuditSummary\].*status=PASS$", re.M), + "seams": re.compile(r"^\[PassageTileSeamAudit\].*status=PASS$", re.M), + "shell": re.compile(r"^\[PassageShellAuditSummary\].*status=PASS$", re.M), + "naturalness": re.compile(r"^\[PassageNaturalnessSummary\].*status=PASS$", re.M), + "mouth_profile": re.compile(r"^\[PassageMouthProfileSummary\].*status=PASS$", re.M), + "ripple": re.compile(r"^\[PassageRippleAuditSummary\].*status=PASS$", re.M), + "route_negative_control": re.compile( + r"^\[TunnelNetworkBlockedRouteControl\].*expected=FAIL status=PASS$", re.M), +} + + +def main() -> int: + seeds = [int(value) for value in sys.argv[1:]] or list(range(16)) + if not BIN.is_file() or not DATA.is_file(): + raise SystemExit("missing L136 headless binary or owner fixture") + OUT.mkdir(parents=True, exist_ok=True) + results = [] + for seed in seeds: + log = OUT / f"seed{seed}.log" + layout = OUT / f"seed{seed}.json" + command = ["taskset", "-c", "0-11", "prlimit", "--as=6442450944", "--", + "timeout", "1740s", str(BIN), str(DATA), + "--world-assembler-prototype", "--stream-benchmark", "--stream-pipeline", + "--workers=8", "--clip-radius=3", "--max-clip-level=8", "--max-level=0", + "--force-generate", f"--seed={seed}", "--recipe=surface-world", + "--audit-resolved-layout-passages", "--audit-passage-tile-seams", + f"--resolved-layout-output={layout}"] + 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) + content = log.read_text(encoding="utf-8", errors="replace") + found_stamp = STAMP_RE.search(content) + checks = {name: bool(pattern.search(content)) for name, pattern in REQUIRED.items()} + checks["source_stamp"] = found_stamp is not None and found_stamp.group(1) == STAMP + blocked_controls = re.findall( + r"^\[ResolvedPassageBlockedControl\].*detected=true$", content, re.M) + checks["three_blocked_controls"] = len(blocked_controls) == 3 + passed = result.returncode == 0 and all(checks.values()) + row = {"seed": seed, "exit": result.returncode, "passed": passed, + "checks": checks, "blocked_controls": len(blocked_controls), + "elapsed_s": round(time.monotonic() - started, 3), + "log": str(log.relative_to(ROOT)), "layout": str(layout.relative_to(ROOT))} + results.append(row) + print("[L136SeedSweep] " + json.dumps(row, sort_keys=True), flush=True) + (OUT / "runs-partial.json").write_text(json.dumps(results, indent=2) + "\n") + if not passed: + raise SystemExit(f"seed {seed} failed a composed audit; see {log}") + summary = {"source_stamp": STAMP, "seeds": seeds, "passed": len(results), + "failed": 0, "results": results} + (OUT / "summary.json").write_text(json.dumps(summary, indent=2) + "\n") + print(f"[L136SeedSweepSummary] passed={len(results)}/{len(seeds)} status=PASS") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/Standalone/Research/WorldAssemblerM3/Linux136/RunL136Timing.py b/Standalone/Research/WorldAssemblerM3/Linux136/RunL136Timing.py new file mode 100644 index 0000000..817a612 --- /dev/null +++ b/Standalone/Research/WorldAssemblerM3/Linux136/RunL136Timing.py @@ -0,0 +1,136 @@ +#!/usr/bin/env python3 +"""Five interleaved L80 timings for assembler/world, v236, and v239.""" +from __future__ import annotations + +import json +import os +import re +import statistics +import subprocess +import time +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[4] +OUT = ROOT / "Saved/Linux/l136/timing" +DATA = ROOT / "Standalone/data/owner_world.json" +BINARIES = { + "assembler-world": (ROOT / "Saved/Linux/l130/bin/VoxelForgeCoreHeadless-l130-clang", + "8b3e7bfb4cde2b408ab940925eab973d8375d6b719774d6f72f64ee72b526c35"), + "v236": (ROOT / "Saved/Linux/l135/bin/VoxelForgeCoreHeadless-clang-l135", + "8dc4294ce0250a591ee4515471c3c547e796ffa4346ab44f0ae1740bbc3797f5"), + "v239": (ROOT / "Saved/Linux/l136/bin/VoxelForgeCoreHeadless-l136-clang", + "ebe6b32a7cd96c5aa69c6dc64ae6b9c6ff4bc18bc484efc5148611c48723c28f"), +} +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), +} +PIPELINE_RE = re.compile(r"^\[StreamPipeline\] (.*)$", re.M) +FIELDS_RE = re.compile(r"([a-zA-Z0-9_]+)=([^ ]+)") +NEAR_RE = re.compile( + r"^\[WorldAssemblerNearLODReady\] lods=0-2 tiles=(\d+)/(\d+) cold_ready_s=([0-9.]+)$", + re.M) +STAMP_RE = re.compile(r"^\[VoxelForgeSourceStamp\] sha256=([0-9a-f]+)$", re.M) +PLAN_RE = re.compile(r"^\[WorldAssemblerPlanTiming\] total_ms=([0-9.]+) status=([^ ]+)$", re.M) +CAVE_RE = re.compile(r"^\[CavernPlannerV1\].* plan_ms=([0-9.]+) status=([^ ]+)$", re.M) + + +def run(strate: int, workers: int, version: str, phase: str, + replicate: int) -> dict: + binary, expected_stamp = BINARIES[version] + camera = ",".join(f"{value:.12f}" for value in CAMERAS[strate]) + ",0,0" + label = f"s{strate}-w{workers}-{version}-{phase}{replicate}" + log = OUT / f"{label}.log" + command = ["taskset", "-c", "0-11", "prlimit", "--as=6442450944", "--", + "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 output: + result = subprocess.run(command, cwd=ROOT, stdout=output, + stderr=subprocess.STDOUT, check=False, timeout=1740) + content = log.read_text(encoding="utf-8", errors="replace") + pipeline, near, stamp = (PIPELINE_RE.search(content), NEAR_RE.search(content), + STAMP_RE.search(content)) + if (result.returncode or pipeline is None or near is None or stamp is None + or stamp.group(1) != expected_stamp): + raise SystemExit(f"L80 timing failed/stamp mismatch: {log}; exit={result.returncode}") + fields = dict(FIELDS_RE.findall(pipeline.group(1))) + plan, cave = PLAN_RE.search(content), CAVE_RE.search(content) + row = {"strate": strate, "workers": workers, "version": version, + "phase": phase, "replicate": replicate, "source_stamp": stamp.group(1), + "lod02_ready_s": float(near.group(3)), + "whole_view_ready_s": float(fields["whole_view_ready"].removesuffix("s")), + "plan_ms": float(plan.group(1)) if plan else None, + "cave_plan_ms": float(cave.group(1)) if cave else None, + "wall_s": round(time.monotonic() - started, 3), + "log": str(log.relative_to(ROOT))} + print("[L136TimingRun] " + json.dumps(row, sort_keys=True), flush=True) + return row + + +def quiet_machine() -> tuple[float, float]: + load_1m = os.getloadavg()[0] + def totals() -> tuple[int, int]: + fields = Path("/proc/stat").read_text().splitlines()[0].split() + values = [int(value) for value in fields[1:]] + return sum(values), values[3] + values[4] + before = totals() + time.sleep(2.0) + after = totals() + idle = 100.0 * (after[1] - before[1]) / max(1, after[0] - before[0]) + return load_1m, idle + + +def main() -> int: + if any(not path.is_file() for path, _ in BINARIES.values()) or not DATA.is_file(): + raise SystemExit("missing L136 timing input") + OUT.mkdir(parents=True, exist_ok=True) + load_1m, idle = quiet_machine() + (OUT / "machine-load-before.txt").write_text( + f"1-minute load: {load_1m:.2f}\n2-second CPU idle: {idle:.1f}%\n") + print(f"[L136TimingGate] load_1m={load_1m:.2f} cpu_idle_2s={idle:.1f}%", flush=True) + if load_1m >= 0.9 or idle < 97.0: + raise SystemExit("timing refused: machine is above the L80 quiet-load gate") + + rows = [] + for strate in range(4): + for workers in (8, 12): + for version in BINARIES: + run(strate, workers, version, "warmup", 0) + for replicate in range(1, 6): + order = tuple(BINARIES) if replicate % 2 else tuple(reversed(BINARIES)) + for version in order: + rows.append(run(strate, workers, version, "measured", replicate)) + (OUT / "runs-partial.json").write_text(json.dumps(rows, indent=2) + "\n") + + measured = [row for row in rows if row["phase"] == "measured"] + summary = [] + for strate in range(4): + for workers in (8, 12): + item = {"strate": strate, "workers": workers, "replicates_per_version": 5} + medians = {} + for version in BINARIES: + group = [row for row in measured if row["strate"] == strate + and row["workers"] == workers and row["version"] == version] + medians[version] = {} + for key in ("lod02_ready_s", "whole_view_ready_s"): + values = [row[key] for row in group] + medians[version][key] = statistics.median(values) + item[f"{version}_{key}_values"] = values + item[f"{version}_{key}_median"] = medians[version][key] + for baseline in ("assembler-world", "v236"): + for key in ("lod02_ready_s", "whole_view_ready_s"): + item[f"v239_vs_{baseline}_{key}_delta_pct"] = round( + 100.0 * (medians["v239"][key] / medians[baseline][key] - 1.0), 2) + summary.append(item) + (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())