diff options
author | Zhaozhong Ni <nzz@google.com> | 2018-05-08 10:06:14 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-05-08 10:07:10 -0700 |
commit | fea624b37a90c0e1efc0c1e7ae7dda7b2d1a0050 (patch) | |
tree | a5993ef86b85bf7d23a8d50007c24c9029da957e /pkg/state/statefile/statefile.go | |
parent | 09c323910d7f28fec9e4c92e5faaa92bb63bd431 (diff) |
Sentry: always use "best speed" compression for save and remove the option.
PiperOrigin-RevId: 195835861
Change-Id: Ib696b1b571a6b061725a33c535cd7215fe518b97
Diffstat (limited to 'pkg/state/statefile/statefile.go')
-rw-r--r-- | pkg/state/statefile/statefile.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/pkg/state/statefile/statefile.go b/pkg/state/statefile/statefile.go index b25b743b7..64b0a6312 100644 --- a/pkg/state/statefile/statefile.go +++ b/pkg/state/statefile/statefile.go @@ -45,6 +45,7 @@ package statefile import ( "bytes" + "compress/flate" "crypto/hmac" "crypto/sha256" "encoding/json" @@ -86,7 +87,7 @@ var ErrMetadataInvalid = fmt.Errorf("metadata invalid, can't start with _") // NewWriter returns a state data writer for a statefile. // // Note that the returned WriteCloser must be closed. -func NewWriter(w io.Writer, key []byte, metadata map[string]string, compressionLevel int) (io.WriteCloser, error) { +func NewWriter(w io.Writer, key []byte, metadata map[string]string) (io.WriteCloser, error) { if metadata == nil { metadata = make(map[string]string) } @@ -140,8 +141,11 @@ func NewWriter(w io.Writer, key []byte, metadata map[string]string, compressionL w = hashio.NewWriter(w, h) - // Wrap in compression. - return compressio.NewWriter(w, compressionChunkSize, compressionLevel) + // Wrap in compression. We always use "best speed" mode here. When using + // "best compression" mode, there is usually only a little gain in file + // size reduction, which translate to even smaller gain in restore + // latency reduction, while inccuring much more CPU usage at save time. + return compressio.NewWriter(w, compressionChunkSize, flate.BestSpeed) } // MetadataUnsafe reads out the metadata from a state file without verifying any |