Skip to content
This repository was archived by the owner on Feb 1, 2020. It is now read-only.

Commit 7bad53c

Browse files
Zhaozhong Nishentubot
Zhaozhong Ni
authored andcommitted
Sentry: always use "best speed" compression for save and remove the option.
PiperOrigin-RevId: 195835861 Change-Id: Ib696b1b571a6b061725a33c535cd7215fe518b97 Upstream-commit: fea624b
1 parent fdb75e6 commit 7bad53c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pkg/state/statefile/statefile.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ package statefile
4545

4646
import (
4747
"bytes"
48+
"compress/flate"
4849
"crypto/hmac"
4950
"crypto/sha256"
5051
"encoding/json"
@@ -86,7 +87,7 @@ var ErrMetadataInvalid = fmt.Errorf("metadata invalid, can't start with _")
8687
// NewWriter returns a state data writer for a statefile.
8788
//
8889
// Note that the returned WriteCloser must be closed.
89-
func NewWriter(w io.Writer, key []byte, metadata map[string]string, compressionLevel int) (io.WriteCloser, error) {
90+
func NewWriter(w io.Writer, key []byte, metadata map[string]string) (io.WriteCloser, error) {
9091
if metadata == nil {
9192
metadata = make(map[string]string)
9293
}
@@ -140,8 +141,11 @@ func NewWriter(w io.Writer, key []byte, metadata map[string]string, compressionL
140141

141142
w = hashio.NewWriter(w, h)
142143

143-
// Wrap in compression.
144-
return compressio.NewWriter(w, compressionChunkSize, compressionLevel)
144+
// Wrap in compression. We always use "best speed" mode here. When using
145+
// "best compression" mode, there is usually only a little gain in file
146+
// size reduction, which translate to even smaller gain in restore
147+
// latency reduction, while inccuring much more CPU usage at save time.
148+
return compressio.NewWriter(w, compressionChunkSize, flate.BestSpeed)
145149
}
146150

147151
// MetadataUnsafe reads out the metadata from a state file without verifying any

0 commit comments

Comments
 (0)