My session files were ~3GB (2,000+ files). I first tried a Node.js approach but it took 40+ seconds – sequential JSON.parse, GC overhead, and libuv thread pool limits made it hard to optimize further.
Rewrote it in Rust with simd-json (SIMD-accelerated parsing) + rayon (parallel file processing). Cold start: ~1s, warm: ~0.04s.
Also supports Codex CLI and Gemini CLI.
Install: npx toktrack
toktrack caches cost data independently either way, so past history is preserved regardless.