Skip to content

feat: Update Stream to accept a bufSize for tar CopyBuffer window (#26964)#27077

Merged
devanbenz merged 1 commit into1.12from
db/cherrypick-abd617f
Jan 2, 2026
Merged

feat: Update Stream to accept a bufSize for tar CopyBuffer window (#26964)#27077
devanbenz merged 1 commit into1.12from
db/cherrypick-abd617f

Conversation

@devanbenz
Copy link
Copy Markdown

io.Copy & io.CopyN uses a default window size of 32KB during copy

Copy(N) calls copyBuffer with buf set to nil https://cs.opensource.google/go/go/+/refs/tags/go1.25.4:src/io/io.go;l=387-389

When buf is nil go will set the default buffer size to 32KB https://cs.opensource.google/go/go/+/refs/tags/go1.25.4:src/io/io.go;l=418

This PR replaces io.CopyN with io.CopyBuffer in tar.Stream. It also adds a new configuration value tar-stream-buffer-size which can be adjusted to allow for larger or smaller tar buffer sizes to be used during backup operations.

It is suggested to keep the default as is, while testing different buffer sizes to be used with CopyBuffer I found that 1MB was the best performance-wise.

(cherry picked from commit abd617f)

…6964)

`io.Copy` & `io.CopyN` uses a default window size of 32KB during copy

`Copy(N)` calls `copyBuffer` with `buf` set to `nil`
https://cs.opensource.google/go/go/+/refs/tags/go1.25.4:src/io/io.go;l=387-389

When `buf` is `nil` go will set the default buffer size to 32KB
https://cs.opensource.google/go/go/+/refs/tags/go1.25.4:src/io/io.go;l=418

This PR replaces `io.CopyN` with `io.CopyBuffer` in `tar.Stream`. It also adds a new configuration value `tar-stream-buffer-size` which can be adjusted to allow for larger or smaller tar buffer sizes to be used during backup operations.

It is suggested to keep the default as is, while testing different buffer sizes to be used with `CopyBuffer` I found that `1MB` was the best performance-wise.

(cherry picked from commit abd617f)
Copy link
Copy Markdown
Contributor

@davidby-influx davidby-influx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@devanbenz devanbenz merged commit bac5ced into 1.12 Jan 2, 2026
9 checks passed
@devanbenz devanbenz deleted the db/cherrypick-abd617f branch January 2, 2026 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update Stream to accept a bufSize for tar CopyBuffer window [port to 1.12]

2 participants