perf(filer): pre-size chunk stream reader buffer to view size

The chunk size is known up front, so grow the buffer once instead of
letting bytes.Buffer double as the streamed pieces arrive (which
transiently overshoots to ~2x per reader).
This commit is contained in:
Chris Lu
2026-06-09 09:52:41 -07:00
parent 65a1aef769
commit 8725c06420
+2
View File
@@ -484,6 +484,8 @@ func (c *ChunkStreamReader) fetchChunkToBuffer(chunkView *ChunkView) error {
return err
}
var buffer bytes.Buffer
// pre-size to the known chunk size; avoids bytes.Buffer's doubling regrowth
buffer.Grow(int(chunkView.ViewSize))
var shouldRetry bool
jwt := JwtForVolumeServer(chunkView.FileId)
for _, urlString := range urlStrings {