Files
xenia-rs/audit-runs/phase-c18-shared-global-race/truncate.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

49 lines
1.5 KiB
Python

#!/usr/bin/env python3
"""Per-tid truncation for canary JSONL logs.
Canary's full boot log can exceed 800 MB; the diff tool loads the
entire file into RAM. We only need enough events per tid to walk past
the first divergence — anything beyond is dead weight. Cap each tid at
a configurable max (default: 250k for tid=6 main, 20k for others)."""
import json
import sys
from pathlib import Path
MAIN_CAP = 250_000 # tid=6 (canary's main chain — mapped to ours tid=1)
SISTER_CAP = 20_000 # everything else
def main() -> int:
src = Path(sys.argv[1])
dst = Path(sys.argv[2])
counts: dict[int, int] = {}
kept = 0
total = 0
with src.open("r", encoding="utf-8") as fin, dst.open("w", encoding="utf-8") as fout:
for lineno, line in enumerate(fin, start=1):
if lineno == 1:
fout.write(line)
continue
total += 1
try:
ev = json.loads(line)
except json.JSONDecodeError:
continue
tid = ev.get("tid", 0)
cap = MAIN_CAP if tid == 6 else SISTER_CAP
c = counts.get(tid, 0)
if c >= cap:
continue
counts[tid] = c + 1
fout.write(line)
kept += 1
print(f"kept {kept}/{total} events across {len(counts)} tids")
for tid in sorted(counts):
print(f" tid={tid:4d} {counts[tid]}")
return 0
if __name__ == "__main__":
sys.exit(main())