Skip to content

Commit bd7d2d4

Browse files
committed
perf(ccusage): speed up usage data loading
Parse common usage JSONL rows with a lightweight hot path before falling back to JSON parsing and structural validation. Daily loading now reads JSONL files concurrently up to the available CPU parallelism capped at 16, then applies dedupe in file order so output ordering and duplicate handling stay stable. Benchmark: mitata on Apple M3 Pro, node 24.15.0, built JS CLI at apps/ccusage/dist/index.js, Rust release CLI at /Users/ryoppippi/ghq/github.com/ryoppippi/ccusage/target/release/ccusage, LOG_LEVEL=0, --offline --json, min_samples=5. Results: JS daily 3.85s, session 3.99s, monthly 3.94s, blocks 8.36s. Rust daily 630.05ms, session 643.02ms, monthly 622.38ms, blocks 649.11ms. Previous local baseline after duplicate-entry fixes: JS daily 4.09s, session 3.91s, monthly 4.00s, blocks 8.60s; Rust daily 641ms, session 701ms, monthly 694ms, blocks 644ms. Correctness: built JS and Rust outputs matched for daily/session/monthly/blocks token totals after sorting by stable keys. Cost totals can still differ by floating-point formatting only. Verification: pnpm run format; pnpm typecheck; pnpm --filter ccusage exec vitest run src/data-loader.ts; pnpm --filter ccusage run build; pnpm run test.
1 parent d5a1921 commit bd7d2d4

1 file changed

Lines changed: 323 additions & 56 deletions

File tree

0 commit comments

Comments
 (0)