Commit ca9b3a5
committed
perf(ccusage): scan Bun block JSONL bytes
Extend the Bun JSONL byte-scan path to block loading. Usage rows are still decoded and parsed through the existing fast parser, while non-usage block timestamps are extracted directly from bytes so block loading avoids decoding every JSONL line on Bun. Node keeps the existing text/file-handle path.
On real local Claude data with LOG_LEVEL=0 and COLUMNS=200, the combined Bun byte-scan path improved the pre-byte baseline from daily JSON 419.9ms ± 6.2ms to 362.7ms ± 7.6ms, session JSON 450.2ms ± 20.9ms to 378.0ms ± 9.3ms, and blocks JSON 551.4ms ± 9.2ms to 462.2ms ± 13.8ms. Table output saw the same shape: daily 431.2ms ± 21.5ms to 368.1ms ± 6.9ms, session 442.7ms ± 5.7ms to 379.8ms ± 7.7ms, and blocks 552.9ms ± 12.9ms to 462.8ms ± 12.3ms.
Current Rust #977 reference from the same host remains faster: JS daily 368.2ms ± 15.0ms vs Rust 292.9ms ± 4.1ms, JS session 376.4ms ± 10.9ms vs Rust 298.3ms ± 5.5ms, and JS blocks 449.1ms ± 8.0ms vs Rust 297.7ms ± 5.4ms.
Validation: pnpm run format; pnpm typecheck; pnpm --filter ccusage exec vitest run src/data-loader.ts --testNamePattern loadSessionBlockData\|loadDailyUsageData\|loadSessionData; pnpm --filter ccusage run build; pnpm run test; Bun/Node JSON parity for daily/session/blocks/monthly/weekly; table parity for daily/session/blocks.1 parent bb2ebe9 commit ca9b3a5
1 file changed
Lines changed: 53 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
| |||
233 | 234 | | |
234 | 235 | | |
235 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
236 | 259 | | |
237 | 260 | | |
238 | 261 | | |
| |||
2008 | 2031 | | |
2009 | 2032 | | |
2010 | 2033 | | |
2011 | | - | |
| 2034 | + | |
2012 | 2035 | | |
2013 | 2036 | | |
2014 | 2037 | | |
| |||
2083 | 2106 | | |
2084 | 2107 | | |
2085 | 2108 | | |
2086 | | - | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
| 2125 | + | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
| 2134 | + | |
| 2135 | + | |
| 2136 | + | |
| 2137 | + | |
2087 | 2138 | | |
2088 | 2139 | | |
2089 | 2140 | | |
| |||
0 commit comments