trace-server: shrink reader buffers, compact eagerly
The accumulation buffer only compacted on reaching capacity, and extend_from_slice doubles, so with a 64 MB read chunk it ratcheted upward instead of staying near one chunk. On a 62 MB trace it held essentially the whole file: 687 MB live for a 62 MB input. To fix, we read 4 MB instead of 64 MB, and drop the consumed prefix as soon as we finish each parse. We are essentially left with one partial row. This is safe to change, because the format's re-used row vec borrows directly from the buffer within a read call and is dropped before returning. At our artificial (but reproducible) STOP_AT=2000, that reduces live heap by ~600 MB at ~7M spans. I alternated through 4/8/16/64 MB buffers, and found it didn't affect read time because of the underlying IO, so a large buffer buys us nothing but memory accumulation.
Showing
Please
register
or
sign in
to comment