@@ -12,6 +12,7 @@ import (
12
12
"math"
13
13
"os"
14
14
"path/filepath"
15
+ "runtime"
15
16
"sort"
16
17
"strconv"
17
18
"strings"
@@ -224,6 +225,19 @@ func RegisterCompressionAlgorithmClusterSetting(
224
225
)
225
226
}
226
227
228
+ var defaultCompressionAlgorithm = func () CompressionAlgorithm {
229
+ if runtime .GOARCH == "amd64" {
230
+ // We prefer MinLZ on amd64 because it is slightly superior to Snappy in
231
+ // almost all cases (both in terms of speed and compression ratio).
232
+ //
233
+ // Only amd64 has an optimized assembly MinLZ implementation; the Go
234
+ // implementation is significantly slower, especially when decompressing;
235
+ // see https://github.com/minio/minlz#protobuf-sample
236
+ return CompressionAlgorithmMinLZ
237
+ }
238
+ return CompressionAlgorithmSnappy
239
+ }()
240
+
227
241
// CompressionAlgorithmStorage determines the compression algorithm used to
228
242
// compress data blocks when writing sstables for use in a Pebble store (written
229
243
// directly, or constructed for ingestion on a remote store via AddSSTable).
@@ -232,7 +246,7 @@ func RegisterCompressionAlgorithmClusterSetting(
232
246
var CompressionAlgorithmStorage = RegisterCompressionAlgorithmClusterSetting (
233
247
"storage.sstable.compression_algorithm" ,
234
248
`determines the compression algorithm to use when compressing sstable data blocks for use in a Pebble store;` ,
235
- CompressionAlgorithmMinLZ , // Default.
249
+ defaultCompressionAlgorithm ,
236
250
)
237
251
238
252
// CompressionAlgorithmBackupStorage determines the compression algorithm used
@@ -242,7 +256,7 @@ var CompressionAlgorithmStorage = RegisterCompressionAlgorithmClusterSetting(
242
256
var CompressionAlgorithmBackupStorage = RegisterCompressionAlgorithmClusterSetting (
243
257
"storage.sstable.compression_algorithm_backup_storage" ,
244
258
`determines the compression algorithm to use when compressing sstable data blocks for backup row data storage;` ,
245
- CompressionAlgorithmMinLZ , // Default.
259
+ defaultCompressionAlgorithm ,
246
260
)
247
261
248
262
// CompressionAlgorithmBackupTransport determines the compression algorithm used
@@ -255,7 +269,7 @@ var CompressionAlgorithmBackupStorage = RegisterCompressionAlgorithmClusterSetti
255
269
var CompressionAlgorithmBackupTransport = RegisterCompressionAlgorithmClusterSetting (
256
270
"storage.sstable.compression_algorithm_backup_transport" ,
257
271
`determines the compression algorithm to use when compressing sstable data blocks for backup transport;` ,
258
- CompressionAlgorithmMinLZ , // Default.
272
+ defaultCompressionAlgorithm ,
259
273
)
260
274
261
275
func getCompressionAlgorithm (
0 commit comments