mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 09:08:38 +00:00
windows-boot: summarize device loss API and queue checkpoints
This commit is contained in:
@ -87,6 +87,12 @@ Several records can describe one loss. A driver can also report loss without any
|
||||
Share counts and states on the board. Keep paths, logs, traces, captures and dumps on your machine
|
||||
([AGENTS.md](../../AGENTS.md), "No game data").
|
||||
|
||||
When the log contains a device loss, a fault query outcome or checkpoint records, `fault context` shows the first
|
||||
recognized Vulkan API that reported loss and the first observed fault query outcome. An unrecognized operation is
|
||||
shown as `other`. A missing outcome is `not observed`. The queue count includes queries that returned zero
|
||||
checkpoints. `reported` sums the driver counts from the queue headers. `decoded` and `unrecognized` count the
|
||||
two kinds of printed stage records, so a truncated log can have fewer printed records than reported checkpoints.
|
||||
|
||||
How to read the states: game state goes 1, 2 (init), 3 (running); session state goes 0, 1, 3 (landing
|
||||
screen waiting for A), `d` after A.
|
||||
|
||||
|
||||
@ -473,6 +473,67 @@ if (-not $DigestOnly) {
|
||||
|
||||
# -------------------------------------------------------------------------------------------- the digest
|
||||
|
||||
function Get-FaultContext {
|
||||
param([string]$Path)
|
||||
$apis = @("vkAcquireNextImageKHR", "vkBeginCommandBuffer", "vkCreateSwapchainKHR", "vkDeviceWaitIdle",
|
||||
"vkEndCommandBuffer", "vkGetFenceStatus", "vkGetQueryPoolResults", "vkGetSemaphoreCounterValue",
|
||||
"vkQueueBindSparse", "vkQueuePresentKHR", "vkQueueSubmit", "vkQueueWaitIdle", "vkResetFences",
|
||||
"vkSignalSemaphore", "vkWaitForFences", "vkWaitSemaphores")
|
||||
$api = "not observed"
|
||||
$query = "not observed"
|
||||
$lost = $false
|
||||
[long]$queues = 0
|
||||
[long]$reported = 0
|
||||
[long]$decoded = 0
|
||||
[long]$unrecognized = 0
|
||||
|
||||
# Select-String streams matches, including a report that arrives after a long trace.
|
||||
$prefix = '^\s*\[rt\] (device-fault: |vulkan: the device was lost \()'
|
||||
Select-String -LiteralPath $Path -CaseSensitive -Pattern $prefix | ForEach-Object {
|
||||
$tag = $_.Matches[0]
|
||||
$record = $_.Line.Substring($tag.Length).TrimEnd()
|
||||
if ($tag.Groups[1].Value -eq "vulkan: the device was lost (") {
|
||||
$lost = $true
|
||||
if ($api -in @("not observed", "other")) {
|
||||
if ($record -cmatch '^(vkWaitSemaphores|vkGetSemaphoreCounterValue) in the fence dispatcher returned VK_ERROR_DEVICE_LOST\)') {
|
||||
$api = $Matches[1]
|
||||
} elseif ($record.StartsWith("a fence's counter read UINT64_MAX and vkDeviceWaitIdle then returned VK_ERROR_DEVICE_LOST)")) {
|
||||
$api = "vkDeviceWaitIdle"
|
||||
}
|
||||
}
|
||||
} elseif ($record.StartsWith("VK_ERROR_DEVICE_LOST from ")) {
|
||||
$lost = $true
|
||||
if ($api -in @("not observed", "other")) {
|
||||
$api = "other"
|
||||
if ($record -cmatch '^VK_ERROR_DEVICE_LOST from ([^\s(]+)' -and $apis -ccontains $Matches[1]) {
|
||||
$api = $Matches[1]
|
||||
}
|
||||
}
|
||||
} elseif ($record -cmatch '^queue \S+ checkpoints=([0-9]+)$') {
|
||||
[uint32]$count = 0
|
||||
if ([uint32]::TryParse($Matches[1], [ref]$count)) {
|
||||
$queues++
|
||||
$reported += $count
|
||||
}
|
||||
} elseif ($record -cmatch '^stage=0x[0-9a-fA-F]+ submission=[0-9]+ list=[0-9]+ command=[0-9]+ kind=\S+$') {
|
||||
$decoded++
|
||||
} elseif ($record -cmatch '^stage=0x[0-9a-fA-F]+ marker=\S+ \(unrecognized\)$') {
|
||||
$unrecognized++
|
||||
} elseif ($query -eq "not observed") {
|
||||
if ($record.StartsWith("description:")) {
|
||||
$query = if ($record.EndsWith(" (partial report)")) { "partial" } else { "complete" }
|
||||
} elseif ($record -cmatch '^vkGetDeviceFaultInfoEXT (counts|data) failed \(-?[0-9]+\)$') {
|
||||
$query = "$($Matches[1]) failed"
|
||||
} elseif ($record -ceq "fault info collection failed") {
|
||||
$query = "collection failed"
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($lost -or $query -ne "not observed" -or $queues -or $decoded -or $unrecognized) {
|
||||
"fault context: api=$api, query=$query, queues=$queues, reported=$reported, decoded=$decoded, unrecognized=$unrecognized"
|
||||
}
|
||||
}
|
||||
|
||||
$py = @(Resolve-Python $Python)
|
||||
if ($py.Count) {
|
||||
$pyArgs = @()
|
||||
@ -585,6 +646,10 @@ if ($deviceLost -or $faultClasses.Count) {
|
||||
}
|
||||
$digest.Add("faults: $faultText")
|
||||
if ($wrapped) { $digest.Add("wrapped: $wrapped lines mention wrapped V#s") }
|
||||
if (Test-Path -LiteralPath $LogFile) {
|
||||
$faultContext = Get-FaultContext $LogFile
|
||||
if ($faultContext) { $digest.Add($faultContext) }
|
||||
}
|
||||
$digest.Add("frames: $capText")
|
||||
$digest.Add("files: $LogFile, $TraceFile, $SummaryFile")
|
||||
$digest | Out-File -FilePath $DigestFile -Encoding utf8
|
||||
|
||||
97
tests/test_windows_boot_fault_context.py
Normal file
97
tests/test_windows_boot_fault_context.py
Normal file
@ -0,0 +1,97 @@
|
||||
"""Run the native Windows digest against synthetic device-fault reports."""
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
|
||||
BOOT = Path(__file__).resolve().parents[1] / "scripts" / "windows-boot" / "boot.ps1"
|
||||
POWERSHELL = shutil.which("powershell") or shutil.which("pwsh")
|
||||
FAULT = "[rt] device-fault: "
|
||||
|
||||
|
||||
@unittest.skipUnless(os.name == "nt" and POWERSHELL, "requires PowerShell on Windows")
|
||||
class FaultContextTest(unittest.TestCase):
|
||||
def context(self, lines, newline="\n"):
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
root = Path(folder)
|
||||
(root / "boot.log").write_text("\n".join(lines), encoding="utf-8", newline=newline)
|
||||
(root / "boot.jsonl").write_text('{"kind":"trace_open"}\n', encoding="utf-8", newline="\n")
|
||||
subprocess.run(
|
||||
[POWERSHELL, "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", str(BOOT),
|
||||
"-DigestOnly", "-Name", "boot", "-OutDir", folder, "-SummaryLines", "0",
|
||||
"-Python", sys.executable],
|
||||
check=True, capture_output=True, timeout=60,
|
||||
)
|
||||
digest = (root / "boot.digest.txt").read_text(encoding="utf-8-sig")
|
||||
return [line for line in digest.splitlines() if line.startswith("fault context:")]
|
||||
|
||||
def test_counts_reported_and_printed_checkpoints_separately(self):
|
||||
lines = [FAULT + "submitted dispatch seq=7 queue=0xfe (copy) shader=private"] * 10
|
||||
lines += [FAULT + "VK_ERROR_DEVICE_LOST from vkQueueSubmit (private)",
|
||||
FAULT + "VK_ERROR_DEVICE_LOST from vkQueueWaitIdle",
|
||||
FAULT + "description: private (partial report)",
|
||||
FAULT + "description: second report",
|
||||
FAULT + "queue 00AAAAAA checkpoints=2",
|
||||
FAULT + "stage=0x80 submission=1 list=0 command=2 kind=dispatch",
|
||||
FAULT + "ExecuteCommandLists #1 queue=00AAAAAA (compute) lists=1",
|
||||
FAULT + "last shader pipeline=0x12 shaders=private - -",
|
||||
FAULT + "stage=0x40 marker=00000011 (unrecognized)",
|
||||
FAULT + "queue 00BBBBBB checkpoints=0",
|
||||
FAULT + "ExecuteCommandLists #9 queue=00BBBBBB (copy) lists=1",
|
||||
FAULT + "queue 00CCCCCC checkpoints=3",
|
||||
FAULT + "stage=0x20 submission=2 list=0 command=1 kind=draw",
|
||||
FAULT + "submission metadata unavailable"] # log ends before two stages are printed
|
||||
self.assertEqual(self.context(lines, newline="\r\n"), [
|
||||
"fault context: api=vkQueueSubmit, query=partial, queues=3, reported=5, decoded=2, unrecognized=1"
|
||||
])
|
||||
|
||||
def test_unknown_operation_and_driver_text_do_not_become_labels(self):
|
||||
self.assertEqual(self.context([
|
||||
FAULT + "VK_ERROR_DEVICE_LOST from vkQueueSubmitPrivate (vkWaitForFences)",
|
||||
FAULT + "description: private (partial report) and more",
|
||||
FAULT + "vendor[0] private stage=0x40 marker=12 (unrecognized)",
|
||||
]), ["fault context: api=other, query=complete, queues=0, reported=0, decoded=0, unrecognized=0"])
|
||||
|
||||
def test_first_recognized_api_after_an_unknown_operation(self):
|
||||
rows = self.context([FAULT + "VK_ERROR_DEVICE_LOST from private",
|
||||
" " + FAULT + "VK_ERROR_DEVICE_LOST from vkCreateSwapchainKHR (DXGI)"])
|
||||
self.assertEqual(rows, [
|
||||
"fault context: api=vkCreateSwapchainKHR, query=not observed, queues=0, reported=0, decoded=0, unrecognized=0"
|
||||
])
|
||||
|
||||
def test_query_failures_in_truncated_reports(self):
|
||||
for detail, outcome in [("vkGetDeviceFaultInfoEXT counts failed (-4)", "counts failed"),
|
||||
("vkGetDeviceFaultInfoEXT data failed (-4)", "data failed"),
|
||||
("fault info collection failed", "collection failed")]:
|
||||
with self.subTest(detail=detail):
|
||||
self.assertEqual(self.context([FAULT + detail]), [
|
||||
f"fault context: api=not observed, query={outcome}, queues=0, reported=0, decoded=0, unrecognized=0"
|
||||
])
|
||||
|
||||
def test_runtime_loss_without_diagnostics(self):
|
||||
reasons = [
|
||||
("vkWaitSemaphores in the fence dispatcher returned VK_ERROR_DEVICE_LOST", "vkWaitSemaphores"),
|
||||
("a fence's counter read UINT64_MAX and vkDeviceWaitIdle then returned VK_ERROR_DEVICE_LOST", "vkDeviceWaitIdle"),
|
||||
("a Vulkan call returned VK_ERROR_DEVICE_LOST", "not observed"),
|
||||
]
|
||||
for reason, api in reasons:
|
||||
with self.subTest(reason=reason):
|
||||
rows = self.context([f"[rt] vulkan: the device was lost ({reason}); its fences now read UINT64_MAX"])
|
||||
self.assertEqual(rows, [
|
||||
f"fault context: api={api}, query=not observed, queues=0, reported=0, decoded=0, unrecognized=0"
|
||||
])
|
||||
|
||||
def test_normal_dispatches_and_quoted_diagnostics_do_not_create_context(self):
|
||||
self.assertEqual(self.context([FAULT + "enabled (fault info on, checkpoints on, NVIDIA diagnostics config on)",
|
||||
FAULT + "submitted dispatch seq=7 queue=0xfe (copy) shader=private",
|
||||
FAULT + "queue 00AAAAAA checkpoints=999999999999999999999",
|
||||
"[rt] title: " + FAULT + "description: private"]), [])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user