Summary
ccusage codex daily on current Rust code still reads each Codex session JSONL file fully into memory before line scanning.
This reproduces the large-session failure mode from #952 for the current unified ccusage codex path. In rust/crates/ccusage/src/codex_loader.rs, visit_codex_session_file used fs::read(path), so a multi-GB Codex session can exhaust memory before the marker filter or aggregation has a chance to run.
Impact
Long-lived Codex Desktop sessions can grow to GB-sized JSONL files. When that happens, npx ccusage@latest codex daily can consume enough memory that macOS starts pausing applications or the process fails before producing a report.
Proposed fix
I opened PR #1123 to stream Codex sessions with BufReader::read_until on newline bytes and reuse the same line buffer, preserving the existing token-count parsing and model tracking behavior while bounding memory to the largest line instead of the whole file.
Local validation
cargo fmt --manifest-path rust/Cargo.toml --all --check
cargo test --manifest-path rust/Cargo.toml -p ccusage codex_loader::tests::parses_codex_usage_from_streaming_reader
cargo test --manifest-path rust/Cargo.toml --workspace
cargo clippy --manifest-path rust/Cargo.toml --workspace --all-targets -- -D warnings
- Release binary smoke test with a ~95 MB synthetic Codex session fixture via
CODEX_HOME=/private/tmp/ccusage-codex-large-fixture rust/target/release/ccusage codex daily --offline --json
Summary
ccusage codex dailyon current Rust code still reads each Codex session JSONL file fully into memory before line scanning.This reproduces the large-session failure mode from #952 for the current unified
ccusage codexpath. Inrust/crates/ccusage/src/codex_loader.rs,visit_codex_session_fileusedfs::read(path), so a multi-GB Codex session can exhaust memory before the marker filter or aggregation has a chance to run.Impact
Long-lived Codex Desktop sessions can grow to GB-sized JSONL files. When that happens,
npx ccusage@latest codex dailycan consume enough memory that macOS starts pausing applications or the process fails before producing a report.Proposed fix
I opened PR #1123 to stream Codex sessions with
BufReader::read_untilon newline bytes and reuse the same line buffer, preserving the existing token-count parsing and model tracking behavior while bounding memory to the largest line instead of the whole file.Local validation
cargo fmt --manifest-path rust/Cargo.toml --all --checkcargo test --manifest-path rust/Cargo.toml -p ccusage codex_loader::tests::parses_codex_usage_from_streaming_readercargo test --manifest-path rust/Cargo.toml --workspacecargo clippy --manifest-path rust/Cargo.toml --workspace --all-targets -- -D warningsCODEX_HOME=/private/tmp/ccusage-codex-large-fixture rust/target/release/ccusage codex daily --offline --json