0
Fork 0
mirror of https://github.com/TanStack/router.git synced 2026-11-16 19:38:07 +00:00
router/packages/start-client-core/tests
Flo c59788ca20
perf(start-client-core): O(1) buffer drain in client frame decoder (#8009)
The frame decoder dropped consumed chunks from its buffer with
bufferList.shift(), which is O(n). When a single large frame (e.g. a big
RawStream payload) is assembled from many small network reads, the
extract loop calls shift() once per chunk, making reassembly O(n^2).

Track the first un-consumed chunk with a head pointer and advance it in
O(1) instead of shifting. Consumed slots are released for GC, and the
buffer is compacted when fully drained (O(1) reset) or once the consumed
prefix grows past a small threshold (amortized O(1) per chunk).

A micro-benchmark draining 1000 small chunks is ~11x faster.

Co-authored-by: Yagiz Nizipli <yagiz@nizipli.com>
History 2026-08-08 19:20:41 +02:00
..
frame-decoder.test.ts perf(start-client-core): O(1) buffer drain in client frame decoder (#8009) 2026-08-08 19:20:41 +02:00
hydration-runtime.test.ts perf(start): compact deferred hydration private state (#7980) 2026-08-07 17:30:30 +02:00
hydration-visible.test.ts perf(start): compact deferred hydration private state (#7980) 2026-08-07 17:30:30 +02:00