wip(standalone): GPU step 7 partial -- parity check deferred off cold path (stopped early)

Luna measured the startup density-parity check at 1,049 ms, nearly all of the
~1.13 s before shape compile; it now runs after first display and still passes
3,436/3,436. CPU hashes 44/44 at 1 and 8 workers, walkability 5,642/5,642,
headless 8-worker clipmap 0.769 s. Stopped by the owner mid-round, while
auditing the remote far holes; first-launch stall and hybrid speed untouched.

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-06 20:17:37 +02:00
1 parent b0a14262b1
commit 41716f00b8
6 files changed
+198 -24

No files matched your search

@@ -554,36 +554,46 @@ namespace
void CompileShaders(const std::filesystem::path& shaderPath)
{
const auto PipelineStart=std::chrono::steady_clock::now();
const auto Load=[&](const char* entry)
{
const auto LoadStart=std::chrono::steady_clock::now();
const std::filesystem::path binary=shaderPath.parent_path().parent_path()
/"gpu_field_port"/"precompiled"/(std::string(entry)+".cso");
ComPtr<ID3DBlob> code;
if(std::filesystem::exists(binary)
&&SUCCEEDED(D3DReadFileToBlob(binary.c_str(),&code)))return code;
return CompileShader(shaderPath,entry);
bool precompiled=std::filesystem::exists(binary)
&&SUCCEEDED(D3DReadFileToBlob(binary.c_str(),&code));
if(!precompiled)code=CompileShader(shaderPath,entry);
std::printf("[GpuPipelineProfile] stage=bytecode_load entry=%s source=%s duration_ms=%.3f\n",
entry,precompiled?"precompiled":"runtime_compile",
std::chrono::duration<double,std::milli>(std::chrono::steady_clock::now()-LoadStart).count());
return code;
};
ComPtr<ID3DBlob> code = Load("EvaluateFarFieldCS");
Check(device->CreateComputeShader(code->GetBufferPointer(), code->GetBufferSize(), nullptr, &fieldEval), "CreateComputeShader(EvaluateFarFieldCS)");
code = Load("ClassifyCS");
Check(device->CreateComputeShader(code->GetBufferPointer(), code->GetBufferSize(), nullptr, &classify), "CreateComputeShader(ClassifyCS)");
code = Load("ClassifyFarCS");
Check(device->CreateComputeShader(code->GetBufferPointer(), code->GetBufferSize(), nullptr, &fieldClassify), "CreateComputeShader(ClassifyFarCS)");
code = Load("ScanGroupsCS");
Check(device->CreateComputeShader(code->GetBufferPointer(), code->GetBufferSize(), nullptr, &scan), "CreateComputeShader(ScanGroupsCS)");
code = Load("EmitCS");
Check(device->CreateComputeShader(code->GetBufferPointer(), code->GetBufferSize(), nullptr, &emit), "CreateComputeShader(EmitCS)");
code = Load("NoiseProbeCS");
Check(device->CreateComputeShader(code->GetBufferPointer(), code->GetBufferSize(), nullptr, &noiseProbe), "CreateComputeShader(NoiseProbeCS)");
code = Load("BuildFarConnectorRingsCS");
Check(device->CreateComputeShader(code->GetBufferPointer(), code->GetBufferSize(), nullptr, &connectorRings), "CreateComputeShader(BuildFarConnectorRingsCS)");
code = Load("EmitFarConnectorPanelsCS");
Check(device->CreateComputeShader(code->GetBufferPointer(), code->GetBufferSize(), nullptr, &connectorPanels), "CreateComputeShader(EmitFarConnectorPanelsCS)");
const auto Create=[&](const char* entry,ComPtr<ID3D11ComputeShader>& shader)
{
ComPtr<ID3DBlob> code=Load(entry);
const auto CreateStart=std::chrono::steady_clock::now();
const std::string operation="CreateComputeShader("+std::string(entry)+")";
Check(device->CreateComputeShader(code->GetBufferPointer(),code->GetBufferSize(),nullptr,&shader),operation.c_str());
std::printf("[GpuPipelineProfile] stage=shader_object_create entry=%s duration_ms=%.3f\n",
entry,std::chrono::duration<double,std::milli>(std::chrono::steady_clock::now()-CreateStart).count());
};
Create("EvaluateFarFieldCS",fieldEval);
Create("ClassifyCS",classify);
Create("ClassifyFarCS",fieldClassify);
Create("ScanGroupsCS",scan);
Create("EmitCS",emit);
Create("NoiseProbeCS",noiseProbe);
Create("BuildFarConnectorRingsCS",connectorRings);
Create("EmitFarConnectorPanelsCS",connectorPanels);
std::printf("[GpuPipelineProfile] stage=shader_pipeline_total duration_ms=%.3f\n",
std::chrono::duration<double,std::milli>(std::chrono::steady_clock::now()-PipelineStart).count());
}
void InitializeExternal(ID3D11Device* inDevice, ID3D11DeviceContext* inContext,
const std::filesystem::path& shaderPath)
{
const auto InitializeStart=std::chrono::steady_clock::now();
device = inDevice;
immediateContext = inContext;
context = immediateContext;
@@ -595,6 +605,8 @@ namespace
if(SUCCEEDED(device.As(&dxgiDevice))&&SUCCEEDED(dxgiDevice->GetAdapter(&adapter)))
adapter.As(&memoryAdapter);
CompileShaders(shaderPath);
std::printf("[GpuPipelineProfile] stage=external_device_init device=%s duration_ms=%.3f\n",
name.c_str(),std::chrono::duration<double,std::milli>(std::chrono::steady_clock::now()-InitializeStart).count());
}
void BeginFarTileBatch()
@@ -639,6 +651,7 @@ namespace
void Initialize(const std::filesystem::path& shaderPath, bool warp)
{
const auto InitializeStart=std::chrono::steady_clock::now();
D3D_FEATURE_LEVEL requested[] = {D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0};
D3D_FEATURE_LEVEL created{};
HRESULT hr = D3D11CreateDevice(nullptr,
@@ -664,6 +677,8 @@ namespace
adapter.As(&memoryAdapter);
}
CompileShaders(shaderPath);
std::printf("[GpuPipelineProfile] stage=audit_device_init device=%s duration_ms=%.3f\n",
name.c_str(),std::chrono::duration<double,std::milli>(std::chrono::steady_clock::now()-InitializeStart).count());
}
bool QueryLocalMemory(std::uint64_t& usage, std::uint64_t& budget) const
@@ -0,0 +1,58 @@
[CmdletBinding()]
param([string]$ExecutableName='VoxelForgeGpuFieldStep7NearTimeline.exe')
$ErrorActionPreference='Stop'
$HostProcess=Get-Process -Id $PID
$HostProcess.PriorityClass='BelowNormal'
$HostProcess.ProcessorAffinity=[IntPtr]0xFF00
$StandaloneRoot=[IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..\..\..'))
$ExecutablePath=Join-Path $StandaloneRoot ('bin\'+$ExecutableName)
if([IO.Path]::GetFileName($ExecutableName)-ne$ExecutableName-or[IO.Path]::GetExtension($ExecutableName)-ne'.exe')
{throw 'ExecutableName must be an executable filename.'}
if(-not(Test-Path -LiteralPath $ExecutablePath -PathType Leaf)){throw "Viewer not found: $ExecutablePath"}
$Sequence=@(
@{Mode='cpu';Name='step7_interleaved_cpu_A'},
@{Mode='gpu';Name='step7_interleaved_gpu_A'},
@{Mode='gpu';Name='step7_interleaved_gpu_B'},
@{Mode='cpu';Name='step7_interleaved_cpu_B'},
@{Mode='cpu';Name='step7_interleaved_cpu_C'},
@{Mode='gpu';Name='step7_interleaved_gpu_C'}
)
foreach($Run in $Sequence)
{
$Arguments=@('--clip-radius=3','--workers=8','--quit-after-clipmap',"--$($Run.Mode)-far")
$StdoutPath=Join-Path $PSScriptRoot ($Run.Name+'.stdout.log')
$StderrPath=Join-Path $PSScriptRoot ($Run.Name+'.stderr.log')
Write-Output "COLD_RUN mode=$($Run.Mode) command=`"$ExecutablePath`" $($Arguments -join ' ')"
for($Attempt=0;$Attempt-lt2;$Attempt++)
{
if($Attempt-gt0)
{Write-Host '0xC0000142 encountered; waiting 60 seconds before the single permitted retry.';Start-Sleep -Seconds 60}
Remove-Item -LiteralPath $StdoutPath,$StderrPath -Force -ErrorAction SilentlyContinue
$Child=Start-Process -FilePath $ExecutablePath -ArgumentList $Arguments -WorkingDirectory $StandaloneRoot `
-WindowStyle Hidden -PassThru -RedirectStandardOutput $StdoutPath -RedirectStandardError $StderrPath
$PeakWorkingSet=0L;$PeakPrivateMemory=0L;$OverMemoryLimit=$false
while(-not$Child.HasExited)
{
$Child.Refresh();if($Child.HasExited){break}
$Child.PriorityClass='BelowNormal';$Child.ProcessorAffinity=[IntPtr]0xFF00
$PeakWorkingSet=[Math]::Max($PeakWorkingSet,$Child.WorkingSet64)
$PeakPrivateMemory=[Math]::Max($PeakPrivateMemory,$Child.PrivateMemorySize64)
if($Child.PrivateMemorySize64-ge8GB)
{$OverMemoryLimit=$true;$Child.Kill();$Child.WaitForExit();break}
Start-Sleep -Milliseconds 100
}
$Child.WaitForExit();$Child.Refresh()
$ExitCode=0
if($null-ne$Child.ExitCode){$ExitCode=[int]$Child.ExitCode}
if($ExitCode-eq-1073741502-and$Attempt-eq0){continue}
if($ExitCode-eq-1073741502){throw '0xC0000142 repeated after its single retry; stopping.'}
if($OverMemoryLimit){throw "Viewer stopped at the private-memory limit: $($Run.Name)"}
$LogText=Get-Content -LiteralPath $StdoutPath -Raw
if(-not$LogText.Contains('[InitialClipmapReady]'))
{throw "Clipmap was not ready in $($Run.Name); exit=$ExitCode"}
Write-Output "RUN_EXIT mode=$($Run.Mode) log=$($Run.Name) pid=$($Child.Id) priority=BelowNormal affinity=0xFF00 peak_working_set_gb=$([math]::Round($PeakWorkingSet/1GB,2)) peak_private_gb=$([math]::Round($PeakPrivateMemory/1GB,2)) exit=$ExitCode"
if($ExitCode-ne0){throw "Cold run returned $ExitCode`: $($Run.Name)"}
break
}
}
@@ -0,0 +1,51 @@
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)][string]$ExecutableName,
[Parameter(Mandatory=$true)][string]$LogStem,
[string[]]$Arguments=@(),
[string]$RequiredText=''
)
$ErrorActionPreference='Stop'
$HostProcess=Get-Process -Id $PID
$HostProcess.PriorityClass='BelowNormal'
$HostProcess.ProcessorAffinity=[IntPtr]0xFF00
$StandaloneRoot=[IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..\..\..'))
$ExecutablePath=Join-Path $StandaloneRoot ('bin\'+$ExecutableName)
if([IO.Path]::GetFileName($ExecutableName)-ne$ExecutableName-or[IO.Path]::GetExtension($ExecutableName)-ne'.exe')
{throw 'ExecutableName must be an executable filename.'}
if(-not(Test-Path -LiteralPath $ExecutablePath -PathType Leaf)){throw "Executable not found: $ExecutablePath"}
$StdoutPath=Join-Path $PSScriptRoot ($LogStem+'.stdout.log')
$StderrPath=Join-Path $PSScriptRoot ($LogStem+'.stderr.log')
Write-Output "STEP7_COMMAND `"$ExecutablePath`" $($Arguments -join ' ')"
for($Attempt=0;$Attempt-lt2;$Attempt++)
{
if($Attempt-gt0)
{Write-Output '0xC0000142 encountered; waiting 60 seconds before the single permitted retry.';Start-Sleep -Seconds 60}
Remove-Item -LiteralPath $StdoutPath,$StderrPath -Force -ErrorAction SilentlyContinue
$Child=Start-Process -FilePath $ExecutablePath -ArgumentList $Arguments -WorkingDirectory $StandaloneRoot `
-WindowStyle Hidden -PassThru -RedirectStandardOutput $StdoutPath -RedirectStandardError $StderrPath
$PeakWorkingSet=0L;$PeakPrivateMemory=0L;$OverMemoryLimit=$false
while(-not$Child.HasExited)
{
$Child.Refresh();if($Child.HasExited){break}
$Child.PriorityClass='BelowNormal';$Child.ProcessorAffinity=[IntPtr]0xFF00
$PeakWorkingSet=[Math]::Max($PeakWorkingSet,$Child.WorkingSet64)
$PeakPrivateMemory=[Math]::Max($PeakPrivateMemory,$Child.PrivateMemorySize64)
if($Child.PrivateMemorySize64-ge8GB)
{$OverMemoryLimit=$true;$Child.Kill();$Child.WaitForExit();break}
Start-Sleep -Milliseconds 100
}
$Child.WaitForExit();$Child.Refresh()
$ExitCode=0
if($null-ne$Child.ExitCode){$ExitCode=[int]$Child.ExitCode}
if($ExitCode-eq-1073741502-and$Attempt-eq0){continue}
if($ExitCode-eq-1073741502){throw '0xC0000142 repeated after its single retry; stopping.'}
if($OverMemoryLimit){throw "Process stopped at the 8 GiB private-memory limit: $LogStem"}
$LogText=Get-Content -LiteralPath $StdoutPath -Raw
if($RequiredText-and-not$LogText.Contains($RequiredText))
{throw "Required output '$RequiredText' missing from $LogStem; exit=$($Child.ExitCode)"}
Write-Output "STEP7_EXIT log=$LogStem pid=$($Child.Id) priority=BelowNormal affinity=0xFF00 peak_working_set_gb=$([math]::Round($PeakWorkingSet/1GB,2)) peak_private_gb=$([math]::Round($PeakPrivateMemory/1GB,2)) exit=$ExitCode stdout=$StdoutPath stderr=$StderrPath"
if($ExitCode-ne0){throw "Process returned $ExitCode`: $LogStem"}
break
}