perf(rl): decouple diagnostic JSON writer to background thread
The 94KB per-step JSON record (130 fields, per-batch unit arrays) took ~150ms CPU to build+serialize, blocking the GPU pipeline that only needs ~13ms. Training was CPU-bound at 6.2 sps. New architecture: training loop snapshots DiagFrame data (~0.1ms memcpy from mapped-pinned to owned Vecs), sends via non-blocking try_send on sync_channel(1). Background writer thread builds JSON and writes to BufWriter at its own pace. Drops frames under backpressure — acceptable for diagnostics. Training loop per-step: 13ms GPU + 0.1ms snapshot = ~13.1ms. Expected: ~50-77 sps at b=1024 on L40S (was 6.2). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in: