wip(assembler): round S5 -- streaming gates + trace; coarse-first order kept opt-in (no win)

Walkable/enclosed/refined gates defined; JSONL trace joins request, worker start,
build/apply and discards. Coarse-first + dynamic near reserve behind
voxel.StreamingCoarseFirst / voxel.StreamingDynamicNearReserve (default 0 =
S4 order): matched runs showed no walkability or full-view win and slower
LOD0/1 refinement. Instruments settled: 3.1 s standalone reproduced (16.7 s was
another generation route); black early captures were clear-only frames.
Hashes equal S4; Core-off, M2, SurfaceWorld/FloatingIslands BuildHost pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MmSoF64BbRFmk9C3p1VsBJ
This commit is contained in:
Fr0zkaandClaude Opus 5.5 committed 2026-10-19 04:42:41 +02:00
1 parent 9d3c50ca95
commit c0596c5f24
32 files changed
+1049 -65

No files matched your search

@@ -5,6 +5,8 @@
#include "Misc/CommandLine.h"
#include "Misc/Parse.h"
#include <atomic>
namespace VoxelForgeStartupTrace
{
namespace
@@ -27,6 +29,7 @@ namespace
FCriticalSection GTraceLock;
TUniquePtr<FState> GState;
std::atomic<bool> GTraceActive{false};
FString JsonEscape(const FString& In)
{
@@ -49,9 +52,8 @@ namespace
const FString WithNewline = Line + TEXT("\n");
FTCHARToUTF8 Utf8(*WithNewline);
State.Archive->Serialize(const_cast<ANSICHAR*>(Utf8.Get()), Utf8.Length());
// The trace is intended to remain readable if a harness terminates the editor after
// the steady-state record. This is bounded I/O (startup only), not the shared UE log.
State.Archive->Flush();
// The file archive buffers records; flushing every tile/request can stall the game thread.
// L'archive tamponne les lignes ; vider apres chaque tuile/requete peut bloquer le thread de jeu.
}
void WriteEventLocked(FState& State, const TCHAR* Type, const FString& FieldsJson)
@@ -203,6 +205,7 @@ void BeginFromCommandLine()
NewState->StartSeconds = FPlatformTime::Seconds();
NewState->bActive = true;
GState = MoveTemp(NewState);
GTraceActive.store(true, std::memory_order_release);
WriteEventLocked(*GState, TEXT("header"), FString::Printf(
TEXT("\"schema\":1,\"path\":\"%s\",\"tile_record_cap\":%d"),
*JsonEscape(GState->Path), GState->TileRecordCap));
@@ -210,8 +213,7 @@ void BeginFromCommandLine()
bool IsActive()
{
FScopeLock Lock(&GTraceLock);
return GState.IsValid() && GState->bActive;
return GTraceActive.load(std::memory_order_acquire);
}
void RecordEvent(const TCHAR* Type, const FString& FieldsJson)
@@ -221,6 +223,18 @@ void RecordEvent(const TCHAR* Type, const FString& FieldsJson)
WriteEventLocked(*GState, Type, FieldsJson);
}
void RecordRequest(const FTileSample& Sample, uint32 Epoch)
{
FScopeLock Lock(&GTraceLock);
if (!GState.IsValid() || !GState->bActive) return;
WriteEventLocked(*GState, TEXT("request"), FString::Printf(
TEXT("\"tile\":[%d,%d,%d],\"level\":%d,\"priority\":%d,"
"\"request_ordinal\":%llu,\"epoch\":%u,\"resident_at_request\":%d"),
Sample.TileX, Sample.TileY, Sample.TileZ, Sample.Level, Sample.WorkPriority,
static_cast<unsigned long long>(Sample.RequestOrdinal), Epoch,
Sample.bResidentAtRequest ? 1 : 0));
}
void StageBegin(const TCHAR* Name)
{
if (Name == nullptr) return;
@@ -266,11 +280,17 @@ void RecordTile(const FTileSample& Sample)
GState->Samples.Add(Sample);
++GState->TileRecordsWritten;
WriteEventLocked(*GState, TEXT("tile"), FString::Printf(
TEXT("\"tile\":[%d,%d,%d],\"level\":%d,\"verdict\":%d,\"proof\":%d,\"empty\":%d,\"vertices\":%d,\"triangles\":%d,\"geometry_bytes\":%llu,"
TEXT("\"tile\":[%d,%d,%d],\"level\":%d,\"priority\":%d,"
"\"request_ordinal\":%llu,\"generation_ordinal\":%llu,\"resident_at_request\":%d,"
"\"verdict\":%d,\"proof\":%d,\"empty\":%d,\"vertices\":%d,\"triangles\":%d,\"geometry_bytes\":%llu,"
"\"request_to_apply_s\":%s,\"queue_wait_s\":%s,\"worker_queue_s\":%s,\"result_queue_s\":%s,"
"\"generation_s\":%s,\"classify_s\":%s,\"mesh_s\":%s,\"stream_s\":%s,\"apply_s\":%s"),
Sample.TileX, Sample.TileY, Sample.TileZ,
Sample.Level, Sample.Verdict, Sample.bSealedSolidProof ? 1 : 0,
Sample.Level, Sample.WorkPriority,
static_cast<unsigned long long>(Sample.RequestOrdinal),
static_cast<unsigned long long>(Sample.GenerationOrdinal),
Sample.bResidentAtRequest ? 1 : 0,
Sample.Verdict, Sample.bSealedSolidProof ? 1 : 0,
Sample.bEmpty ? 1 : 0, Sample.Vertices, Sample.Triangles,
static_cast<unsigned long long>(Sample.GeometryBytes),
*Number(Sample.RequestToApplySeconds), *Number(Sample.QueueWaitSeconds),
@@ -283,6 +303,7 @@ void Finish(const TCHAR* Reason)
{
FScopeLock Lock(&GTraceLock);
if (!GState.IsValid() || !GState->bActive) return;
GTraceActive.store(false, std::memory_order_release);
// Close any stage left open by an abnormal early exit so the summary remains useful.
const double Now = FPlatformTime::Seconds();