Files
xenia-rs/audit-runs/review-a-step2-natural-trigger/extract_ours_tid1_full.py
MechaCat02 ef93a4fa14 handoff: VSync/event-wedge fixes + iterate 2.A–2.BC research notes
Source changes (dormant parity infra, retained from iterate 2.AI/2.AO):
- xenia-kernel/exports.rs: nt_create_event manual_reset polarity +
  related event wiring
- xenia-gpu/mmio_region.rs: D1MODE_VBLANK_VLINE_STATUS hardcode parity

Also lands the audit-runs/ analysis notes (.md/.txt/.json digests) for the
iterate 2.x VSync/0x10e8/0x1004 wedge investigation. Raw trace dumps
(.jsonl/.gz/.csv/.stdout) and agent worktrees (.claude/) are gitignored as
regenerable local artifacts — see memory + HANDOFF for the running findings.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-05 07:19:08 +02:00

87 lines
3.0 KiB
Python

#!/usr/bin/env python3
"""Extract ours tid=1 timeline, focused on the final wedge region.
Ours wedges by ~1.7s, so we want the FINAL kernel-call sequence ours emits
on tid=1 before the wait that wedges. Compare against canary tid=6 at a
matching matched-prefix point.
"""
import json
import os
from collections import Counter
INPUT = "/home/fabi/RE - Project Sylpheed/xenia-rs/audit-runs/phase-w-wedge-reattack/ours-postfix.jsonl"
OUTDIR = os.path.dirname(os.path.abspath(__file__))
TARGET_TID = 1
kernel_calls = []
kernel_returns = []
handle_creates = []
thread_events = []
import_calls = []
wait_events = []
other = []
last_idx = -1
last_host_ns = 0
with open(INPUT, "r") as f:
for line in f:
try:
ev = json.loads(line)
except json.JSONDecodeError:
continue
if ev.get("tid") != TARGET_TID:
continue
kind = ev.get("kind", "")
last_idx = ev.get("tid_event_idx", last_idx)
last_host_ns = ev.get("host_ns", last_host_ns)
if kind == "kernel.call":
kernel_calls.append(ev)
elif kind == "kernel.return":
kernel_returns.append(ev)
elif kind == "handle.create":
handle_creates.append(ev)
elif kind in ("thread.create", "thread.exit"):
thread_events.append(ev)
elif kind == "import.call":
import_calls.append(ev)
elif kind in ("wait.begin", "wait.end", "wait.wake"):
wait_events.append(ev)
else:
other.append(ev)
print(f"Ours tid={TARGET_TID} total kernel.call: {len(kernel_calls)}")
print(f"Ours tid={TARGET_TID} last tid_event_idx: {last_idx}")
print(f"Ours tid={TARGET_TID} last host_ns: {last_host_ns} ({last_host_ns/1e9:.3f} s)")
call_counts = Counter()
for ev in kernel_calls:
call_counts[ev["payload"].get("name", "?")] += 1
# Show LAST 100 events on tid=1 to identify the wedge approach.
last_evts = []
for ev in kernel_calls + kernel_returns + wait_events + handle_creates + thread_events:
last_evts.append((ev["host_ns"], ev["tid_event_idx"], ev["kind"], ev["payload"]))
last_evts.sort()
last_evts = last_evts[-150:]
with open(os.path.join(OUTDIR, "ours-tid1-final-150.csv"), "w") as f:
f.write("host_ns,tid_event_idx,kind,name,detail\n")
for host_ns, idx, kind, payload in last_evts:
name = payload.get("name", "")
detail = json.dumps(payload)[:300].replace('"', '""')
f.write(f'{host_ns},{idx},{kind},{name},"{detail}"\n')
with open(os.path.join(OUTDIR, "ours-tid1-summary"), "w") as f:
f.write(f"Ours tid={TARGET_TID} summary\n")
f.write(f"\nTotal kernel.call: {len(kernel_calls)}\n")
f.write(f"Last tid_event_idx: {last_idx}\n")
f.write(f"Last host_ns: {last_host_ns} ({last_host_ns/1e9:.3f} s)\n")
f.write(f"\n=== Top kernel.call by frequency ===\n")
for name, c in call_counts.most_common(80):
f.write(f" {c:6d} {name}\n")
f.write(f"\n=== Unique kernel.call names ===\n")
f.write(f" {len(call_counts)}\n")
print(f"Wrote ours-tid1-final-150.csv")
print(f"Wrote ours-tid1-summary")