Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,9 @@ Compare two completed artifact folders without modifying them:
The console shows raw cold/warm duration, exit/timeout state, stall totals/counts/maxima, the five
compute-build coalescing counters, and ranked-preload submissions, starts and promotions. The
allocator section also reports execute/chunk topology, retirement-signal outcomes, mark writes and
allocator-state lock timing. The redirected JSON keeps those values, raw deltas, and stall log2
allocator-state lock timing. Sparse upload-gate submit/readback wait and hold times are summed from
the activity log; artifacts from older builds label those counters missing rather than zero. The
redirected JSON keeps those values, raw deltas, and stall log2
histograms. Missing reports or preparation summaries and unsupported preparation versions remain
explicit states; they are not treated as zero. The tool
refuses different workload fingerprints or identity algorithm/versions, run order, requested
Expand Down
50 changes: 50 additions & 0 deletions scripts/perf-compare.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,40 @@ function Read-Preparation([string]$Root, [int]$Order, [string]$Label) {
return [ordered]@{ status = 'present'; counters = $counters; ranked_status = 'present'; ranked = $ranked; allocator_status = 'present'; allocator = $allocator }
}

function Read-SparseUploadGate([string]$Root, [int]$Order, [string]$Label) {
$mode = $Label.Substring(4)
$log = Join-Path $Root (Join-Path 'runs' (Join-Path ('{0:d2}-{1}' -f $Order, $mode) 'xcl.log'))
if (-not (Test-Path -LiteralPath $log -PathType Leaf)) {
return [ordered]@{ status = 'missing_log'; counters = $null }
}
$text = Get-Content -LiteralPath $log -Raw -Encoding utf8
$marker = 'upload gate submit wait/hold'
$pattern = 'upload gate submit wait/hold (?<submit_wait>\d+)/(?<submit_hold>\d+) ms, readback wait/hold/released wait\+reacquire (?<readback_wait>\d+)/(?<readback_hold>\d+)/(?<readback_released>\d+) ms'
$matches = [regex]::Matches($text, $pattern)
$markers = [regex]::Matches($text, [regex]::Escape($marker))
if ($matches.Count -ne $markers.Count) {
throw "malformed sparse upload-gate metrics in $log"
}
if ($matches.Count -eq 0) {
return [ordered]@{ status = 'missing_metrics'; counters = $null }
}
$counters = [ordered]@{
submit_wait_ms = [decimal]0
submit_hold_ms = [decimal]0
readback_wait_ms = [decimal]0
readback_hold_ms = [decimal]0
readback_released_wait_reacquire_ms = [decimal]0
}
foreach ($match in $matches) {
$counters.submit_wait_ms += [decimal]$match.Groups['submit_wait'].Value
$counters.submit_hold_ms += [decimal]$match.Groups['submit_hold'].Value
$counters.readback_wait_ms += [decimal]$match.Groups['readback_wait'].Value
$counters.readback_hold_ms += [decimal]$match.Groups['readback_hold'].Value
$counters.readback_released_wait_reacquire_ms += [decimal]$match.Groups['readback_released'].Value
}
return [ordered]@{ status = 'present'; counters = $counters }
}

function Number-Or-Null($Object, [string]$Name) {
if ($null -eq $Object -or -not (Has-Property $Object $Name) -or $null -eq $Object.$Name) { return $null }
return [long]$Object.$Name
Expand Down Expand Up @@ -264,6 +298,11 @@ for ($i = 0; $i -lt 2; $i++) {
'lists_marked', 'backing_mark_writes', 'signal_attempts', 'signal_failures',
'state_lock_wait_ns', 'state_lock_hold_ns')
$allocatorSubmits = Compare-Counters $beforePreparation.allocator $afterPreparation.allocator $allocatorNames
$beforeSparseGate = Read-SparseUploadGate $baselineRoot ($i + 1) $beforeRun.cache_state
$afterSparseGate = Read-SparseUploadGate $candidateRoot ($i + 1) $afterRun.cache_state
$sparseGateNames = @('submit_wait_ms', 'submit_hold_ms', 'readback_wait_ms', 'readback_hold_ms',
'readback_released_wait_reacquire_ms')
$sparseUploadGate = Compare-Counters $beforeSparseGate.counters $afterSparseGate.counters $sparseGateNames

$comparison = [ordered]@{
label = $beforeRun.cache_state
Expand Down Expand Up @@ -297,6 +336,11 @@ for ($i = 0; $i -lt 2; $i++) {
candidate = $afterPreparation.allocator_status
}
allocator_submits = $allocatorSubmits
sparse_upload_gate_status = [ordered]@{
baseline = $beforeSparseGate.status
candidate = $afterSparseGate.status
}
sparse_upload_gate = $sparseUploadGate
}
$comparisons += $comparison

Expand Down Expand Up @@ -327,6 +371,12 @@ for ($i = 0; $i -lt 2; $i++) {
Write-Host " $($name): $(Display-Value $allocatorSubmits.baseline.$name '') -> $(Display-Value $allocatorSubmits.candidate.$name ''); delta $(Display-Value $allocatorSubmits.delta.$name '')"
}
}
Write-Host " sparse upload gate: $($beforeSparseGate.status) -> $($afterSparseGate.status)"
if ($beforeSparseGate.status -eq 'present' -or $afterSparseGate.status -eq 'present') {
foreach ($name in $sparseUploadGate.delta.Keys) {
Write-Host " $($name): $(Display-Value $sparseUploadGate.baseline.$name ' ms') -> $(Display-Value $sparseUploadGate.candidate.$name ' ms'); delta $(Display-Value $sparseUploadGate.delta.$name ' ms')"
}
}
}

[ordered]@{
Expand Down
29 changes: 29 additions & 0 deletions scripts/perf-compare.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ try {
Write-Report (Join-Path $baseline 'runs\01-cold\report.json') 2 100 70 $beforePreparation 3 $beforeRanked $beforeAllocator
Write-Report (Join-Path $candidate 'runs\01-cold\report.json') 3 80 40 $afterPreparation 3 $afterRanked $afterAllocator -ExtraKind
[ordered]@{ d3d12 = [ordered]@{} } | ConvertTo-Json | Set-Content -LiteralPath (Join-Path $baseline 'runs\02-warm\report.json') -Encoding utf8
@(
'[00:00:02] upload gate submit wait/hold 1/2 ms, readback wait/hold/released wait+reacquire 3/4/5 ms; other active work 6 ms'
'[00:00:04] upload gate submit wait/hold 10/20 ms, readback wait/hold/released wait+reacquire 30/40/50 ms; other active work 60 ms'
) | Set-Content -LiteralPath (Join-Path $baseline 'runs\01-cold\xcl.log') -Encoding utf8
'[00:00:02] upload gate submit wait/hold 7/9 ms, readback wait/hold/released wait+reacquire 11/13/15 ms; other active work 17 ms' |
Set-Content -LiteralPath (Join-Path $candidate 'runs\01-cold\xcl.log') -Encoding utf8
'[00:00:02] sparse queue wait/fence+state/scan/upload/ownership wait 1/2/3/4/5 ms' |
Set-Content -LiteralPath (Join-Path $baseline 'runs\02-warm\xcl.log') -Encoding utf8

$json = (& $tool -Baseline $baseline -Candidate $candidate | Out-String) | ConvertFrom-Json
if ($json.schema -ne 'xcl-perf-comparison' -or $json.version -ne 1) { throw 'wrong output schema' }
Expand Down Expand Up @@ -113,6 +121,27 @@ try {
$null -ne $json.runs[1].allocator_submits.delta.chunks) {
throw 'missing preparation data was treated as zero'
}
$gate = $json.runs[0].sparse_upload_gate
if ($json.runs[0].sparse_upload_gate_status.baseline -ne 'present' -or
$json.runs[0].sparse_upload_gate_status.candidate -ne 'present' -or
$gate.baseline.submit_wait_ms -ne 11 -or $gate.baseline.submit_hold_ms -ne 22 -or
$gate.baseline.readback_wait_ms -ne 33 -or $gate.baseline.readback_hold_ms -ne 44 -or
$gate.baseline.readback_released_wait_reacquire_ms -ne 55 -or
$gate.candidate.submit_wait_ms -ne 7 -or $gate.delta.submit_wait_ms -ne -4 -or
$gate.delta.readback_released_wait_reacquire_ms -ne -40) {
throw 'sparse upload-gate counters or deltas are wrong'
}
if ($json.runs[1].sparse_upload_gate_status.baseline -ne 'missing_metrics' -or
$json.runs[1].sparse_upload_gate_status.candidate -ne 'missing_log' -or
$null -ne $json.runs[1].sparse_upload_gate.delta.submit_wait_ms) {
throw 'missing sparse upload-gate metrics were treated as zero'
}
$badGateLog = Join-Path $candidate 'runs\02-warm\xcl.log'
'upload gate submit wait/hold malformed' | Set-Content -LiteralPath $badGateLog -Encoding utf8
$refused = $false
try { $null = & $tool -Baseline $baseline -Candidate $candidate } catch { $refused = $_.Exception.Message -match 'malformed sparse upload-gate metrics' }
Remove-Item -LiteralPath $badGateLog
if (-not $refused) { throw 'a malformed sparse upload-gate activity line was not refused' }
if (($json | ConvertTo-Json -Depth 12) -match '"(percent|percentage|ratio|significance|significant)"\s*:') {
throw 'output invented a derived significance metric'
}
Expand Down