Design decisions

191. Traces are a delta log with periodic snapshots (2026-11-22)

  • Decision. cpl_interp::trace::Recording keeps one small entry per step, write and print, plus a full snapshot of the variables at least every 1024 steps and only once the deltas since the last one outweigh it four times. Step k is rebuilt from the nearest snapshot before it and the deltas after; nothing re-runs. The HTML trace, the DAP and call replay read it through the same methods (len, step, steps, line, place). crates/cpl-interp/tests/trace_log.rs measures the A5 budgets at 10^7 steps (ignored; run by hand in release).
  • Why. A snapshot per step is quadratic in memory for any array program. Measured at 10^7 steps: step back at most 34 µs, the recording 442 MB (scalar loop) and 487 MB (array loop). Recording costs about 2x over the observed run, but tracing is 13-18x the untraced run, because observation forces the tree-walker, which is about 6x slower than the VM. The 3x budget needs the VM to emit the observer events (ARCHITECTURE step 2), not a cheaper log.
  • Reverse. Snapshot every step again in Log::snapshot_if_due; tune SNAPSHOT_EVERY and the 4x ratio to trade memory for step-back time.