[CmdletBinding()] param() $ErrorActionPreference = 'Stop' $HostProcess = Get-Process -Id $PID $HostProcess.PriorityClass = 'BelowNormal' $HostProcess.ProcessorAffinity = [IntPtr]0xFF00 $Standalone = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..\..')) $Executable = Join-Path $Standalone 'bin\VoxelForgeGpuFieldStep6NearProbe.exe' $Stdout = Join-Path $PSScriptRoot 'step6_cpu_hash_fresh_w8.stdout.log' $Stderr = Join-Path $PSScriptRoot 'step6_cpu_hash_fresh_w8.stderr.log' $Arguments = @('--stream-benchmark','--shape-world','--force-generate','--stream-hash','--workers=8','--clip-radius=3') if (-not (Test-Path -LiteralPath $Executable -PathType Leaf)) { throw "Executable not found: $Executable" } for ($Attempt = 0; $Attempt -lt 2; ++$Attempt) { if ($Attempt -eq 1) { Write-Output '0xC0000142 encountered; waiting 60 seconds before the permitted retry.' Start-Sleep -Seconds 60 } $Child = Start-Process -FilePath $Executable -ArgumentList $Arguments -WorkingDirectory $Standalone ` -WindowStyle Hidden -PassThru -RedirectStandardOutput $Stdout -RedirectStandardError $Stderr $PeakWorkingSet = 0L $PeakPrivate = 0L $OverLimit = $false while (-not $Child.HasExited) { $Child.Refresh() if ($Child.HasExited) { break } $Child.PriorityClass = 'BelowNormal' $Child.ProcessorAffinity = [IntPtr]0xFF00 $PeakWorkingSet = [Math]::Max($PeakWorkingSet,$Child.WorkingSet64) $PeakPrivate = [Math]::Max($PeakPrivate,$Child.PrivateMemorySize64) if ($Child.PrivateMemorySize64 -ge 8GB) { $OverLimit = $true $Child.Kill() $Child.WaitForExit() break } Start-Sleep -Milliseconds 100 } $Child.WaitForExit() $Child.Refresh() if ($Child.ExitCode -eq -1073741502 -and $Attempt -eq 0) { continue } if ($Child.ExitCode -eq -1073741502) { throw '0xC0000142 repeated after the one retry; stopping.' } if ($OverLimit) { throw 'CPU hash run stopped at the 8 GB process memory limit.' } $Log = Get-Content -LiteralPath $Stdout -Raw if ($Child.ExitCode -ne 0 -or -not $Log.Contains('[StreamFullClipmap]')) { throw "Hash run failed; exit=$($Child.ExitCode) stdout=$Stdout stderr=$Stderr" } Write-Output "RUN_EXIT pid=$($Child.Id) priority=BelowNormal affinity=0xFF00 peak_working_set_gb=$([Math]::Round($PeakWorkingSet/1GB,2)) peak_private_gb=$([Math]::Round($PeakPrivate/1GB,2)) exit_code=$($Child.ExitCode) stdout=$Stdout stderr=$Stderr" exit 0 }