Skip to content

Commit c89baa6

Browse files
committed
perf(codex): stream usage aggregation
Stream Codex session files instead of reading each JSONL file into memory, and deserialize the hot token_count path into borrowed typed records instead of broad serde_json values. Aggregate directly into report groups for human output so table rendering no longer builds an intermediate JSON tree. Single CODEX_HOME scans now use worker-local dedupe sets and merge them after scanning, avoiding per-event cross-thread locking while preserving the shared-dedupe fallback for overlapping roots. This keeps the release binary at the same size while reducing wall time on a real CODEX_HOME scan and keeps output aligned with bunx ccusage.
1 parent 78b93c2 commit c89baa6

5 files changed

Lines changed: 873 additions & 283 deletions

File tree

‎rust/crates/ccusage-terminal/src/lib.rs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{
22
env,
3-
io::{self, IsTerminal},
3+
io::{self, IsTerminal, Write},
44
};
55

66
#[cfg(unix)]
@@ -79,8 +79,10 @@ impl SimpleTable {
7979
}
8080

8181
pub fn print(&self) {
82+
let stdout = io::stdout();
83+
let mut stdout = stdout.lock();
8284
for line in self.render_lines() {
83-
println!("{line}");
85+
let _ = writeln!(stdout, "{line}");
8486
}
8587
}
8688

0 commit comments

Comments
 (0)