diff options
Diffstat (limited to 'tools/boot_trace.py')
| -rw-r--r-- | tools/boot_trace.py | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/tools/boot_trace.py b/tools/boot_trace.py index db8966f79..e65ab7434 100644 --- a/tools/boot_trace.py +++ b/tools/boot_trace.py | |||
| @@ -32,6 +32,12 @@ import re | |||
| 32 | import sys | 32 | import sys |
| 33 | 33 | ||
| 34 | D3D12_LINE = re.compile(r"^(?:.+ : )?\[d3d12-trace\] #(\d+) (.+) (\S+)\s*$") | 34 | D3D12_LINE = re.compile(r"^(?:.+ : )?\[d3d12-trace\] #(\d+) (.+) (\S+)\s*$") |
| 35 | PACING_LINE = re.compile( | ||
| 36 | r"^(?:.+ : )?\[rt\] present: pacing summary " | ||
| 37 | r"frames=(\d+) samples=(\d+) target_us=(\d+) mean_us=(-?\d+(?:\.\d+)?) drift_us=([+-]?\d+(?:\.\d+)?) " | ||
| 38 | r"p50_us=(\d+) p95_us=(\d+) p99_us=(\d+) " | ||
| 39 | r"latency_samples=(\d+) latency_p50_us=(\d+) latency_p95_us=(\d+) latency_p99_us=(\d+)\s*$" | ||
| 40 | ) | ||
| 35 | D3D12_PROBLEMS = ("failed", "unsupported", "refused", "partial") | 41 | D3D12_PROBLEMS = ("failed", "unsupported", "refused", "partial") |
| 36 | D3D12_OUTCOMES = frozenset((*D3D12_PROBLEMS, "called", "ok", "ignored")) | 42 | D3D12_OUTCOMES = frozenset((*D3D12_PROBLEMS, "called", "ok", "ignored")) |
| 37 | 43 | ||
| @@ -216,10 +222,29 @@ def parse_d3d12(path: str, limit: int = 10) -> dict: | |||
| 216 | "last_seq": 0, | 222 | "last_seq": 0, |
| 217 | "sequence_break_count": 0, | 223 | "sequence_break_count": 0, |
| 218 | "sequence_breaks": [], | 224 | "sequence_breaks": [], |
| 225 | "frame_pacing": None, | ||
| 219 | } | 226 | } |
| 220 | with _open_text(path) as fh: | 227 | with _open_text(path) as fh: |
| 221 | for line in fh: | 228 | for line in fh: |
| 222 | match = D3D12_LINE.match(line.rstrip("\n")) | 229 | stripped = line.rstrip("\n") |
| 230 | pacing_match = PACING_LINE.match(stripped) | ||
| 231 | if pacing_match: | ||
| 232 | trace["frame_pacing"] = { | ||
| 233 | "frames": int(pacing_match.group(1)), | ||
| 234 | "samples": int(pacing_match.group(2)), | ||
| 235 | "target_us": int(pacing_match.group(3)), | ||
| 236 | "mean_us": float(pacing_match.group(4)), | ||
| 237 | "drift_us": float(pacing_match.group(5)), | ||
| 238 | "p50_us": int(pacing_match.group(6)), | ||
| 239 | "p95_us": int(pacing_match.group(7)), | ||
| 240 | "p99_us": int(pacing_match.group(8)), | ||
| 241 | "latency_samples": int(pacing_match.group(9)), | ||
| 242 | "latency_p50_us": int(pacing_match.group(10)), | ||
| 243 | "latency_p95_us": int(pacing_match.group(11)), | ||
| 244 | "latency_p99_us": int(pacing_match.group(12)), | ||
| 245 | } | ||
| 246 | continue | ||
| 247 | match = D3D12_LINE.match(stripped) | ||
| 223 | # A crash can truncate the final outcome. A known complete outcome is | 248 | # A crash can truncate the final outcome. A known complete outcome is |
| 224 | # still usable when the trace ends just before the newline. | 249 | # still usable when the trace ends just before the newline. |
| 225 | if not match or (not line.endswith("\n") and match.group(3) not in D3D12_OUTCOMES): | 250 | if not match or (not line.endswith("\n") and match.group(3) not in D3D12_OUTCOMES): |
| @@ -270,6 +295,7 @@ def counts_only(summary: dict) -> dict: | |||
| 270 | dllmain_failed=startup["dllmain"]["failed"], | 295 | dllmain_failed=startup["dllmain"]["failed"], |
| 271 | unimplemented_imports=len(startup["unimplemented"]), | 296 | unimplemented_imports=len(startup["unimplemented"]), |
| 272 | int3_skipped=len(startup["int3_skipped"]), | 297 | int3_skipped=len(startup["int3_skipped"]), |
| 298 | xmem_physical_pages_count=startup["kinds"].get("xmem_physical_pages", 0), | ||
| 273 | exit_observed=startup["exit"] is not None, | 299 | exit_observed=startup["exit"] is not None, |
| 274 | ) | 300 | ) |
| 275 | if d3d12 := summary["d3d12"]: | 301 | if d3d12 := summary["d3d12"]: |
| @@ -283,6 +309,8 @@ def counts_only(summary: dict) -> dict: | |||
| 283 | "sequence_break_count": d3d12["sequence_break_count"], | 309 | "sequence_break_count": d3d12["sequence_break_count"], |
| 284 | "outcomes": outcomes, | 310 | "outcomes": outcomes, |
| 285 | } | 311 | } |
| 312 | if d3d12.get("frame_pacing") is not None: | ||
| 313 | counters["d3d12"]["frame_pacing"] = dict(d3d12["frame_pacing"]) | ||
| 286 | return counters | 314 | return counters |
| 287 | 315 | ||
| 288 | 316 | ||
| @@ -305,7 +333,8 @@ def format_text(summary: dict, limit: int) -> str: | |||
| 305 | kinds = ", ".join(f"{k} {v}" for k, v in sorted(startup["kinds"].items())) | 333 | kinds = ", ".join(f"{k} {v}" for k, v in sorted(startup["kinds"].items())) |
| 306 | out.append(f" kinds: {kinds}") | 334 | out.append(f" kinds: {kinds}") |
| 307 | if startup["modules"]: | 335 | if startup["modules"]: |
| 308 | names = [m["module"] for m in startup["modules"]] | 336 | # A relocated module is marked: triage step 1 asks whether the executable sits at its preferred base. |
| 337 | names = [m["module"] + (" (relocated)" if m.get("relocated") else "") for m in startup["modules"]] | ||
| 309 | out.append(f" modules ({len(names)}): {_tail(names, limit)}") | 338 | out.append(f" modules ({len(names)}): {_tail(names, limit)}") |
| 310 | out.append(f" tls callbacks: {startup['tls_callbacks']}") | 339 | out.append(f" tls callbacks: {startup['tls_callbacks']}") |
| 311 | if callback := startup.get("last_tls_callback"): | 340 | if callback := startup.get("last_tls_callback"): |
| @@ -382,6 +411,18 @@ def format_text(summary: dict, limit: int) -> str: | |||
| 382 | " (the [rt] diagnostics are not summarized)" | 411 | " (the [rt] diagnostics are not summarized)" |
| 383 | + (f": {outcomes}" if outcomes else "") | 412 | + (f": {outcomes}" if outcomes else "") |
| 384 | ) | 413 | ) |
| 414 | if fp := d3d12.get("frame_pacing"): | ||
| 415 | line = ( | ||
| 416 | f" frame pacing: {fp['frames']} frame(s), {fp['samples']} interval(s), " | ||
| 417 | f"target {fp['target_us']} us, mean {fp['mean_us']:.1f} us (drift {fp['drift_us']:+.1f} us), " | ||
| 418 | f"p50/p95/p99 {fp['p50_us']}/{fp['p95_us']}/{fp['p99_us']} us" | ||
| 419 | ) | ||
| 420 | if fp["latency_samples"]: | ||
| 421 | line += ( | ||
| 422 | f"; origin-to-present p50/p95/p99 " | ||
| 423 | f"{fp['latency_p50_us']}/{fp['latency_p95_us']}/{fp['latency_p99_us']} us" | ||
| 424 | ) | ||
| 425 | out.append(line) | ||
| 385 | if last_call := d3d12.get("last_call"): | 426 | if last_call := d3d12.get("last_call"): |
| 386 | out.append(f" last recorded call: #{last_call['seq']} {last_call['method']} {last_call['outcome']}") | 427 | out.append(f" last recorded call: #{last_call['seq']} {last_call['method']} {last_call['outcome']}") |
| 387 | if d3d12["sequence_break_count"]: | 428 | if d3d12["sequence_break_count"]: |