diff --git a/Standalone/Core/include/VoxelForgeCore/VoxelForgeCore.h b/Standalone/Core/include/VoxelForgeCore/VoxelForgeCore.h index 112f843..9f629df 100644 --- a/Standalone/Core/include/VoxelForgeCore/VoxelForgeCore.h +++ b/Standalone/Core/include/VoxelForgeCore/VoxelForgeCore.h @@ -138,6 +138,7 @@ namespace VoxelForgeCore std::uint64_t passageTileFeatureCount = 0; std::uint64_t passageTileRouteSegmentCandidates = 0; std::uint64_t passageTileMouthSegmentCandidates = 0; + std::uint64_t resolvedBoundaryBandQueries = 0; std::uint64_t passageComposerQueries = 0; std::uint64_t passageIterations = 0; std::uint64_t passageTileBoundChecks = 0; diff --git a/Standalone/Core/src/ShapeWorldInternal.h b/Standalone/Core/src/ShapeWorldInternal.h index 0208e0e..af40c01 100644 --- a/Standalone/Core/src/ShapeWorldInternal.h +++ b/Standalone/Core/src/ShapeWorldInternal.h @@ -31,19 +31,37 @@ #include #include -// L86-only ceiling measurement. This removes passage carving/support and the transition-mouth -// passage fade so timing can measure the best possible passage-representation gain. Never ship -// or expose this diagnostic as a world setting. -static bool VF_IsL86PassageCompositionDisabled() +// L88-only composition split. These switches let the timing harness remove passage work and +// resolved boundary-band work independently. They are diagnostic only, never world settings. +static bool VF_IsL88DiagnosticSwitchEnabled(const char* Name) { - static const bool bDisabled = []() - { - const char* Value = std::getenv("VOXELFORGE_L86_DISABLE_PASSAGE_COMPOSITION"); - return Value && Value[0] == '1' && Value[1] == '\0'; - }(); + const char* Value=std::getenv(Name); + return Value&&Value[0]=='1'&&Value[1]=='\0'; +} + +static bool VF_IsL88PassageCompositionDisabled() +{ + static const bool bDisabled=VF_IsL88DiagnosticSwitchEnabled( + "VOXELFORGE_L88_DISABLE_PASSAGES") + ||VF_IsL88DiagnosticSwitchEnabled("VOXELFORGE_L86_DISABLE_PASSAGE_COMPOSITION"); return bDisabled; } +static bool VF_IsL88BoundaryBandsDisabled() +{ + static const bool bDisabled=VF_IsL88DiagnosticSwitchEnabled( + "VOXELFORGE_L88_DISABLE_BOUNDARY_BANDS") + ||VF_IsL88DiagnosticSwitchEnabled("VOXELFORGE_L86_DISABLE_PASSAGE_COMPOSITION"); + return bDisabled; +} + +static bool VF_IsL88AllowPassageAblationWalkabilityFailure() +{ + static const bool bEnabled=VF_IsL88DiagnosticSwitchEnabled( + "VOXELFORGE_L88_ALLOW_PASSAGE_ABLATION_WALKABILITY_FAILURE"); + return bEnabled; +} + // Standalone-only world compiler. It compiles the runtime room/tunnel/passages into // axis-line intervals, composes rock/cave signs into packed Z-column words, then displaces // only the conservative surface band. The copied Unreal generator remains the A/B reference. @@ -197,7 +215,6 @@ public: std::ptrdiff_t first=-1,end=-1; std::vector activeNodes; }; - FScopedPassageTileQueries(const FStandaloneShapeWorld& shape, const std::array& minimumSubvoxels, const std::array& maximumSubvoxels, @@ -208,7 +225,9 @@ public: { mayContainResolvedBoundaryBand_=shape.ResolvedBoundaryBandsIntersectSubvoxelRange( minimumSubvoxels_[2],maximumSubvoxels_[2]); - const bool disablePassageComposition = VF_IsL86PassageCompositionDisabled(); + const bool disablePassageComposition=VF_IsL88PassageCompositionDisabled(); + const bool disableBoundaryBands=VF_IsL88BoundaryBandsDisabled(); + if(disableBoundaryBands)mayContainResolvedBoundaryBand_=false; mayContainTransitionPassageFade_ = !disablePassageComposition && shape.ResolvedTransitionPassageFadeIntersectsTileXY( minimumSubvoxels_, maximumSubvoxels_); @@ -930,6 +949,9 @@ public: #endif (void)X;(void)Y; const auto* tileQueries=ActivePassageTileQueries; + if(tileQueries&&tileQueries->matches(*this)) + if(auto* profile=tileQueries->profileStats()) + ++profile->resolvedBoundaryBandQueries; if(tileQueries&&tileQueries->matches(*this)) { if(!tileQueries->mayContainResolvedBoundaryBand()) @@ -2256,9 +2278,11 @@ public: // mouth that crosses a wide transition band. Keep that opt-in field whole; // its host-rock value already supplies the ceiling and bedrock. const bool disablePassageComposition=!nativeLattice - &&VF_IsL86PassageCompositionDisabled(); + &&VF_IsL88PassageCompositionDisabled(); + const bool disableBoundaryBands=!nativeLattice + &&VF_IsL88BoundaryBandsDisabled(); float boundary=graphDensity; - if(!nativeLattice&&!disablePassageComposition) + if(!nativeLattice&&!disableBoundaryBands) { VoxelForgeCore::Linux77Profiler::FScopedPhase l77BandsPhase( VoxelForgeCore::Linux77Profiler::EPhase::Bands); @@ -3019,10 +3043,21 @@ public: // Route validation is world-wide. Detail regions reuse the same authored route data and // do not need to repeat the 5,642-point world audit for every entering tile group. Substage=Clock::now(); - if(bValidatePassageRoutes&&!ValidatePassageRoutes()) + const bool bPassageRoutesValid=!bValidatePassageRoutes||ValidatePassageRoutes(); + if(!bPassageRoutesValid) { - Error="compiled shape world contains a solid passage centreline sample"; - return false; + if(VF_IsL88PassageCompositionDisabled() + &&!VF_IsL88BoundaryBandsDisabled() + &&VF_IsL88AllowPassageAblationWalkabilityFailure()) + { + std::printf("[L88PassageAblation] route walkability failed as expected; " + "continuing only to measure passage-off/bands-on readiness\n"); + } + else + { + Error="compiled shape world contains a solid passage centreline sample"; + return false; + } } Stats.PassageValidationSeconds=std::chrono::duration(Clock::now()-Substage).count(); Built=true; diff --git a/Standalone/Research/WorldAssemblerM3/Linux88/REPORT.md b/Standalone/Research/WorldAssemblerM3/Linux88/REPORT.md new file mode 100644 index 0000000..c3911e6 --- /dev/null +++ b/Standalone/Research/WorldAssemblerM3/Linux88/REPORT.md @@ -0,0 +1,35 @@ +# Linux 88 — passage and boundary cost + +## Ceiling split + +L80 protocol: one warmup, then three interleaved measured runs per mode, worker count and stratum. Values are median seconds to LOD0–2 ready / whole view ready. + +| Stratum | Workers | Exact | Passages off, bands on | Bands off, passages on | +|---|---:|---:|---:|---:| +| FI | 8 | 2.419 / 3.696 | 0.808 / 1.738 | 2.306 / 3.556 | +| FI | 12 | 2.273 / 3.463 | 0.812 / 1.683 | 2.114 / 3.290 | +| TN | 8 | 2.458 / 3.624 | 0.912 / 1.814 | 2.222 / 3.308 | +| TN | 12 | 2.253 / 3.294 | 0.851 / 1.683 | 2.056 / 3.061 | + +Passage composition costs about 1.40–1.61 s of FI/TN LOD0–2 readiness. Boundary bands cost about 0.11–0.24 s. The split counters confirmed the ablations: passages-off had zero passage queries, iterations, carve/support visits and relief calls, while retaining 11.39M FI / 7.72M TN band calls in profiled tiles. Bands-off had zero band calls while passage iterations remained 14.06M FI / 12.43M TN. The profile covered 629 FI and 614 TN near tiles. Passage-off intentionally failed the route walkability check because the remaining bands close an authored mouth; a split-only diagnostic continued the timing run. + +Exact-field readiness across all four strates: + +| Stratum | W8 LOD0–2 / whole | W12 LOD0–2 / whole | +|---|---:|---:| +| SurfaceWorld | 1.093 / 2.340 | 1.024 / 2.157 | +| FloatingIslands | 2.419 / 3.696 | 2.273 / 3.463 | +| TunnelNetwork | 2.458 / 3.624 | 2.253 / 3.294 | +| VerticalShafts | 1.312 / 2.386 | 1.128 / 2.080 | + +## Prototype and decision + +I tested a tile-local 4-voxel trilinear cache of passage-composition deltas, with exact evaluation near or across the zero surface. It did not remove enough route work: instrumented FI/TN runs recorded 4.75M / 7.71M exact coarse-node evaluations, and carve-segment visits increased from 34.5M / 33.1M to 56.2M / 76.5M. + +Two unprofiled interleaved W8 pairs confirmed the regression. FI LOD0–2 median rose from 2.583 s exact to 3.765 s coarse; TN rose from 2.646 s to 4.649 s. Whole-view medians rose from 3.957 to 8.708 s for FI and 3.735 to 7.976 s for TN. The prototype was removed from source. + +The pre-measurement acceptance bar was max displacement ≤5 cm, mean ≤1 cm per stratum, and zero sign flips on canonical walk-floor samples. Displacement was not measured. The prototype stopped at the speed gate, so post-prototype passage audits, captures, and Clang/GCC W1/W8/W12 comparisons were not run. No evaluator version bump or hash re-pins were made; version remains 214. The fast tier passed on the cleaned exact-field source: 274 checks in 311.3 s, stamp `81a934b80ed90d2ab0137345d15688a9bd201e4ec6ce7af94b08f4cb4e77c1a3`. + +## Runs + +All benchmark and verification jobs used CPUs 0–11; headless jobs were capped at 6 GiB. No run exceeded 30 minutes. The timing and per-tile work logs are under `Saved/Linux/l88/ceiling-split/` and `Saved/Linux/l88/coarse-prototype/`; the fast-tier log and summary are under `Saved/Linux/l88/logs/fast-tier.log` and `Saved/Linux/l88/verify-fast/fast-summary.json`. No Unreal `Source/` files changed, so no UE build was needed. No commit, push, or stash was made. diff --git a/Standalone/Research/WorldAssemblerM3/Linux88/RunL88CeilingSplit.py b/Standalone/Research/WorldAssemblerM3/Linux88/RunL88CeilingSplit.py new file mode 100644 index 0000000..6fc6c2c --- /dev/null +++ b/Standalone/Research/WorldAssemblerM3/Linux88/RunL88CeilingSplit.py @@ -0,0 +1,198 @@ +#!/usr/bin/env python3 +"""Measure passage and boundary-band ceilings independently under the L80 protocol.""" +from __future__ import annotations + +import argparse +import json +import re +import statistics +import subprocess +import time +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[4] +OUT = ROOT / "Saved/Linux/l88/ceiling-split" +DATA = ROOT / "Standalone/data/owner_world.json" +BINARY = ROOT / "Saved/Linux/l88/bin/VoxelForgeCoreHeadless-l88-clang19" +STRATA = { + "S0": {"id": 0, "camera": (8.0, 16.0, -372.2626953125), "near": 1408, "whole": 2850}, + "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}, + "S3": {"id": 3, "camera": (-20.0625, -5.068359375, -900.353515625), "near": 1344, "whole": 2329}, +} +WORKERS = (8, 12) +MODES = ("direct", "passages_off", "bands_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) +PASSAGE_TILE = re.compile(r"^\[PassageComposerTile\] (.*)$", re.M) +STAMP = re.compile(r"^\[VoxelForgeSourceStamp\] sha256=(\S+)$", re.M) + + +def base_command(stratum: str, workers: int, mode: str, profile: bool = False) -> list[str]: + spec = STRATA[stratum] + camera = ",".join(f"{value:.12f}" for value in spec["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 profile: + child.append("--profile-passage-composer") + env = ["VOXELFORGE_L81_PASSAGE_BOUND_PADDING_VOXELS=0"] + if mode == "passages_off": + env.extend(("VOXELFORGE_L88_DISABLE_PASSAGES=1", + "VOXELFORGE_L88_ALLOW_PASSAGE_ABLATION_WALKABILITY_FAILURE=1")) + elif mode == "bands_off": + env.append("VOXELFORGE_L88_DISABLE_BOUNDARY_BANDS=1") + return [ + "taskset", "-c", "0-11", "prlimit", "--as=6442450944", "--", "env", + *env, "timeout", "1740s", *child, + ] + + +def execute(stratum: str, workers: int, mode: str, phase: str, + replicate: int = 0, profile: bool = False) -> dict: + OUT.mkdir(parents=True, exist_ok=True) + label = f"{stratum.lower()}-w{workers}-{mode}-{phase}" + if replicate: + label += f"-r{replicate}" + if profile: + label += "-profile" + log = OUT / f"{label}.log" + started = time.monotonic() + with log.open("w", encoding="utf-8") as stream: + result = subprocess.run(base_command(stratum, workers, mode, profile), cwd=ROOT, + stdout=stream, stderr=subprocess.STDOUT, + check=False, timeout=1750) + output = log.read_text(encoding="utf-8", errors="replace") + pipeline, near, stamp = PIPELINE.search(output), NEAR.search(output), STAMP.search(output) + if result.returncode or pipeline is None or near is None or stamp is None: + raise RuntimeError(f"run failed or required output is missing: {log}; exit={result.returncode}") + spec = STRATA[stratum] + near_counts = (int(near.group(1)), int(near.group(2))) + if near_counts != (spec["near"], spec["near"]): + raise RuntimeError(f"incomplete near set in {log}: {near_counts}") + fields = dict(FIELDS.findall(pipeline.group(1))) + whole_counts = tuple(int(value) for value in fields["whole_tiles"].split("/")) + if whole_counts != (spec["whole"], spec["whole"]): + raise RuntimeError(f"incomplete whole view in {log}: {whole_counts}") + ablation_walkability = "[L88PassageAblation]" in output + if (mode == "passages_off") != ablation_walkability: + raise RuntimeError(f"passage ablation walkability marker unexpected in {log}") + row = { + "stratum": stratum, "workers": workers, "mode": mode, "phase": phase, + "replicate": replicate, "profile": profile, "exit_code": result.returncode, + "wall_s": round(time.monotonic() - started, 3), "source_stamp": stamp.group(1), + "lod02_ready_s": float(near.group(3)), + "whole_view_ready_s": float(fields["whole_view_ready"].removesuffix("s")), + "shape_s": float(fields["shape"].removesuffix("s")), + "far_shape_s": float(fields["far_shape"].removesuffix("s")), + "ablation_walkability_failed": ablation_walkability, + "near_tiles": spec["near"], "whole_tiles": spec["whole"], + "log": str(log.relative_to(ROOT)), + } + if profile: + total = {name: 0 for name in ( + "boundary_band_queries", "queries", "passage_iterations", + "carve_segment_visits", "support_segment_visits", "relief_field_calls", + )} + profiled_tiles = 0 + for match in PASSAGE_TILE.finditer(output): + fields = dict(FIELDS.findall(match.group(1))) + if int(fields["key"].rsplit("lod", 1)[1].rstrip(")")) > 2: + continue + profiled_tiles += 1 + for name in total: + total[name] += int(fields[name]) + if not profiled_tiles: + raise RuntimeError(f"passage/band profile rows missing in {log}") + row.update({f"profile_{name}": value for name, value in total.items()}) + row["profiled_near_tiles"] = profiled_tiles + print("[L88CeilingSplitRun] " + json.dumps(row, sort_keys=True), flush=True) + return row + + +def profile_modes() -> list[dict]: + rows = [execute(stratum, 8, mode, "profile", profile=True) + for stratum in ("FI", "TN") for mode in MODES] + for stratum in ("FI", "TN"): + subset = {row["mode"]: row for row in rows if row["stratum"] == stratum} + direct, passages, bands = (subset[name] for name in MODES) + if direct["profile_boundary_band_queries"] == 0 or direct["profile_queries"] == 0: + raise RuntimeError(f"direct profile did not exercise both paths for {stratum}") + if passages["profile_boundary_band_queries"] == 0 or any( + passages[f"profile_{name}"] != 0 + for name in ("queries", "passage_iterations", "carve_segment_visits", + "support_segment_visits", "relief_field_calls") + ): + raise RuntimeError(f"passages-off profile did not isolate the band path for {stratum}") + if bands["profile_boundary_band_queries"] != 0 or any( + bands[f"profile_{name}"] == 0 + for name in ("queries", "passage_iterations", "carve_segment_visits") + ): + raise RuntimeError(f"bands-off profile did not preserve passage work for {stratum}") + (OUT / "profile-summary.json").write_text(json.dumps(rows, indent=2) + "\n", encoding="utf-8") + return rows + + +def timing_matrix() -> list[dict]: + # One warmup for each complete stratum/worker/mode window. + for stratum in STRATA: + for workers in WORKERS: + for mode in MODES: + execute(stratum, workers, mode, "warmup") + orders = ( + ((8, "direct"), (8, "passages_off"), (8, "bands_off"), + (12, "bands_off"), (12, "passages_off"), (12, "direct")), + ((12, "passages_off"), (12, "direct"), (12, "bands_off"), + (8, "bands_off"), (8, "direct"), (8, "passages_off")), + ((8, "bands_off"), (8, "direct"), (8, "passages_off"), + (12, "direct"), (12, "passages_off"), (12, "bands_off")), + ) + measured = [] + for stratum in STRATA: + for replicate, order in enumerate(orders, 1): + for workers, mode in order: + measured.append(execute(stratum, workers, mode, "measured", replicate)) + (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: + subset = [r for r in measured if r["stratum"] == stratum + and r["workers"] == workers and r["mode"] == mode] + if len(subset) != 3: + raise RuntimeError(f"expected 3 measured runs for {stratum} W{workers} {mode}") + item = {"stratum": stratum, "workers": workers, "mode": mode, + "measured_runs": len(subset)} + for metric in ("lod02_ready_s", "whole_view_ready_s", "shape_s", "far_shape_s"): + values = [r[metric] for r in subset] + 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 measured + + +def main() -> int: + parser = argparse.ArgumentParser() + parser.add_argument("--profiles-only", action="store_true") + parser.add_argument("--timing-only", action="store_true") + args = parser.parse_args() + if not BINARY.is_file() or not DATA.is_file(): + raise SystemExit(f"missing input: {BINARY} or {DATA}") + if not args.timing_only: + profile_modes() + if not args.profiles_only: + timing_matrix() + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/Standalone/Source/StreamingWorld.h b/Standalone/Source/StreamingWorld.h index 2a2d903..4b192bc 100644 --- a/Standalone/Source/StreamingWorld.h +++ b/Standalone/Source/StreamingWorld.h @@ -1493,13 +1493,14 @@ private: static_cast(D.islandSharedCacheConflictReplacements), static_cast(D.islandSharedCacheLockWaitNanoseconds)/1000.0); if(D.passageComposerProfiled) - std::printf("[PassageComposerTile] key=(%d,%d,%d,lod%d) worker_ms=%.3f samples=%llu native_field_calls=%llu features=%llu route_candidates=%llu mouth_candidates=%llu queries=%llu passage_iterations=%llu tile_bound_checks=%llu tile_bound_rejects=%llu tile_bound_skipped_iterations=%llu upper_mouth_checks=%llu column_candidates=%llu column_distance_calls=%llu negative_bounds=%llu negative_rejects=%llu positive_bounds=%llu positive_rejects=%llu carve_segment_visits=%llu smooth_carve_joins=%llu support_segment_visits=%llu smooth_support_joins=%llu support_capsule_checks=%llu later_bore_checks=%llu other_capsule_checks=%llu mouth_support_calls=%llu mouth_route_segment_checks=%llu relief_field_calls=%llu smoothstep_evaluations=%llu\n", + std::printf("[PassageComposerTile] key=(%d,%d,%d,lod%d) worker_ms=%.3f samples=%llu native_field_calls=%llu features=%llu route_candidates=%llu mouth_candidates=%llu boundary_band_queries=%llu queries=%llu passage_iterations=%llu tile_bound_checks=%llu tile_bound_rejects=%llu tile_bound_skipped_iterations=%llu upper_mouth_checks=%llu column_candidates=%llu column_distance_calls=%llu negative_bounds=%llu negative_rejects=%llu positive_bounds=%llu positive_rejects=%llu carve_segment_visits=%llu smooth_carve_joins=%llu support_segment_visits=%llu smooth_support_joins=%llu support_capsule_checks=%llu later_bore_checks=%llu other_capsule_checks=%llu mouth_support_calls=%llu mouth_route_segment_checks=%llu relief_field_calls=%llu smoothstep_evaluations=%llu\n", Event.Key.Coord.X,Event.Key.Coord.Y,Event.Key.Coord.Z,Event.Key.Level, Event.WorkerMilliseconds,static_cast(Event.DensitySamples), static_cast(D.fieldCalls), static_cast(D.passageTileFeatureCount), static_cast(D.passageTileRouteSegmentCandidates), static_cast(D.passageTileMouthSegmentCandidates), + static_cast(D.resolvedBoundaryBandQueries), static_cast(D.passageComposerQueries), static_cast(D.passageIterations), static_cast(D.passageTileBoundChecks),