Commit ab56ca6
committed
reader (Rust): stream JSONL hot loops; use memchr crate
The Claude / Codex incremental and prescan paths previously built a
multi-GB up-front buffer (`vec![0u8; (size - start_offset) as usize]`,
`Vec::with_capacity((size - start_offset) as usize)` + `read_to_end`)
to scan a session log. Switch to BufReader + `read_until(b'\n', ...)`
into a reused line buffer so only the longest single line stays
resident, regardless of file size.
The main `parse_claude_session` loop also moves off
`BufReader::lines()` (a fresh `String` per line) onto `read_line` into
a reused `String`, keeping per-line allocation bounded by the longest
line for sessions with tens of thousands of turns.
`memchr_newline` in the codex parser was named for `memchr` but did
`buf.iter().position(|&b| b == b'\n')`. Wire the actual `memchr` crate
(already a transitive dep through `regex`) for SIMD-accelerated line
splits; pinned at the workspace root and depended on directly from
`relayburn-sdk` so we own the version.
Closes #323.1 parent 9973768 commit ab56ca6
6 files changed
Lines changed: 94 additions & 44 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
| 99 | + | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
104 | | - | |
105 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
106 | 114 | | |
107 | 115 | | |
108 | 116 | | |
| |||
2290 | 2298 | | |
2291 | 2299 | | |
2292 | 2300 | | |
2293 | | - | |
| 2301 | + | |
2294 | 2302 | | |
2295 | 2303 | | |
2296 | 2304 | | |
| |||
2299 | 2307 | | |
2300 | 2308 | | |
2301 | 2309 | | |
2302 | | - | |
2303 | | - | |
2304 | | - | |
| 2310 | + | |
| 2311 | + | |
| 2312 | + | |
| 2313 | + | |
| 2314 | + | |
| 2315 | + | |
2305 | 2316 | | |
2306 | 2317 | | |
2307 | | - | |
2308 | | - | |
2309 | | - | |
2310 | | - | |
2311 | | - | |
2312 | | - | |
2313 | | - | |
| 2318 | + | |
| 2319 | + | |
| 2320 | + | |
| 2321 | + | |
| 2322 | + | |
| 2323 | + | |
| 2324 | + | |
| 2325 | + | |
| 2326 | + | |
| 2327 | + | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
| 2331 | + | |
| 2332 | + | |
2314 | 2333 | | |
2315 | 2334 | | |
2316 | 2335 | | |
| |||
2499 | 2518 | | |
2500 | 2519 | | |
2501 | 2520 | | |
2502 | | - | |
2503 | | - | |
2504 | | - | |
2505 | | - | |
| 2521 | + | |
| 2522 | + | |
| 2523 | + | |
| 2524 | + | |
| 2525 | + | |
| 2526 | + | |
| 2527 | + | |
2506 | 2528 | | |
2507 | | - | |
2508 | | - | |
2509 | | - | |
2510 | | - | |
2511 | | - | |
2512 | | - | |
2513 | | - | |
2514 | | - | |
2515 | | - | |
| 2529 | + | |
| 2530 | + | |
| 2531 | + | |
| 2532 | + | |
| 2533 | + | |
| 2534 | + | |
| 2535 | + | |
| 2536 | + | |
| 2537 | + | |
| 2538 | + | |
| 2539 | + | |
| 2540 | + | |
| 2541 | + | |
| 2542 | + | |
| 2543 | + | |
| 2544 | + | |
2516 | 2545 | | |
2517 | 2546 | | |
2518 | 2547 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
190 | | - | |
191 | 190 | | |
192 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
193 | 197 | | |
194 | 198 | | |
195 | 199 | | |
196 | | - | |
| 200 | + | |
197 | 201 | | |
198 | 202 | | |
199 | 203 | | |
| |||
330 | 334 | | |
331 | 335 | | |
332 | 336 | | |
333 | | - | |
334 | | - | |
| 337 | + | |
| 338 | + | |
335 | 339 | | |
336 | 340 | | |
337 | 341 | | |
| |||
387 | 391 | | |
388 | 392 | | |
389 | 393 | | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
395 | 402 | | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
400 | 413 | | |
401 | 414 | | |
402 | 415 | | |
| |||
1229 | 1242 | | |
1230 | 1243 | | |
1231 | 1244 | | |
1232 | | - | |
| 1245 | + | |
1233 | 1246 | | |
1234 | 1247 | | |
1235 | 1248 | | |
| |||
0 commit comments