Skip to content

Commit bb3315a

Browse files
committed
Remove additional buffering
Most backed-up files are more than large enough to quickly fill network buffers.
1 parent f64d26f commit bb3315a

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

internal/snapshotstream/stream.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package snapshotstream
22

33
import (
4-
"bufio"
54
"compress/gzip"
65
"crypto/sha256"
76
"encoding/hex"
@@ -93,21 +92,15 @@ func (s *Stream) Status() api.DownloadStatus {
9392
}
9493

9594
func (s *Stream) writeTo(w io.Writer) (err error) {
96-
bufWriter := bufio.NewWriterSize(w, 1024*1024)
97-
98-
defer func() {
99-
multierr.AppendInto(&err, bufWriter.Flush())
100-
}()
101-
10295
var archiveWriter io.Writer
10396
var compressionFlush func() error
10497

10598
switch s.format {
10699
case api.ArchiveTar:
107-
archiveWriter = bufWriter
100+
archiveWriter = w
108101

109102
case api.ArchiveTarGzip:
110-
gzipWriter := gzip.NewWriter(bufWriter)
103+
gzipWriter := gzip.NewWriter(w)
111104
gzipWriter.Header.Name = strings.TrimSuffix(filepath.Base(s.Filename), filepath.Ext(s.Filename))
112105
gzipWriter.Header.Comment = fmt.Sprintf("Prometheus snapshot %s", s.name)
113106

0 commit comments

Comments
 (0)