@@ -45,6 +45,7 @@ package statefile
45
45
46
46
import (
47
47
"bytes"
48
+ "compress/flate"
48
49
"crypto/hmac"
49
50
"crypto/sha256"
50
51
"encoding/json"
@@ -86,7 +87,7 @@ var ErrMetadataInvalid = fmt.Errorf("metadata invalid, can't start with _")
86
87
// NewWriter returns a state data writer for a statefile.
87
88
//
88
89
// 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 ) {
90
91
if metadata == nil {
91
92
metadata = make (map [string ]string )
92
93
}
@@ -140,8 +141,11 @@ func NewWriter(w io.Writer, key []byte, metadata map[string]string, compressionL
140
141
141
142
w = hashio .NewWriter (w , h )
142
143
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 )
145
149
}
146
150
147
151
// MetadataUnsafe reads out the metadata from a state file without verifying any
0 commit comments