Commit bb2ebe9
committed
perf(ccusage): scan Bun JSONL usage bytes
For Bun usage-only JSONL loading, read buffered files with Bun.file().bytes() and scan the byte buffer for the usage marker before decoding only matching usage rows. Node keeps the existing text path, and blocks still uses the full text path because it needs non-usage timestamps.
This avoids decoding the full 1.28GB local JSONL corpus for daily/session commands when most non-usage content is discarded before parsing.
Built Bun JSON A/B against 5db98c7: daily --offline --json 423.3ms ± 7.0ms -> 370.6ms ± 24.7ms (~1.14x faster), session 443.3ms ± 19.1ms -> 373.9ms ± 2.7ms (~1.19x faster), blocks 556.2ms ± 22.0ms -> 549.3ms ± 5.5ms (noise-level, mostly unchanged).
Built Bun table A/B: daily table 426.7ms ± 9.3ms -> 363.0ms ± 9.3ms (~1.18x faster), session table 442.3ms ± 3.8ms -> 384.2ms ± 14.0ms (~1.15x faster), blocks table 560.3ms ± 16.5ms -> 554.5ms ± 10.6ms (noise-level).
Rust reference after this change: JS daily 366.1ms ± 11.9ms vs Rust #977 daily 294.4ms ± 3.5ms (Rust ~1.24x faster); JS session 388.4ms ± 20.4ms vs Rust 300.3ms ± 3.8ms (Rust ~1.29x faster).
Output parity matched the previous built dist for daily/session/blocks/monthly/weekly JSON and daily/session/blocks table output. Node and Bun JSON outputs matched for daily/session/blocks/monthly/weekly. Build size is 404.85 kB. Validation: pnpm run format, pnpm typecheck, targeted data-loader tests, pnpm --filter ccusage run build, and pnpm run test (28 files, 351 passed, 1 skipped).1 parent 5db98c7 commit bb2ebe9
1 file changed
Lines changed: 45 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
861 | 862 | | |
862 | 863 | | |
863 | 864 | | |
| 865 | + | |
864 | 866 | | |
865 | 867 | | |
866 | 868 | | |
| |||
1205 | 1207 | | |
1206 | 1208 | | |
1207 | 1209 | | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
1208 | 1247 | | |
1209 | 1248 | | |
1210 | 1249 | | |
| |||
1264 | 1303 | | |
1265 | 1304 | | |
1266 | 1305 | | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
1267 | 1312 | | |
1268 | 1313 | | |
1269 | 1314 | | |
| |||
0 commit comments