Skip to content

Commit 72bfd41

Browse files
committed
db: add SpanPolicy flag to prefer faster compression
For the same reasons we don't want value separation for some of the local keys, we want to use the faster compression since these keys shouldn't take up a significant amount of space anyway. More generally, we probably want to use the fastest compression for all local keys.
1 parent 430ae82 commit 72bfd41

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

compaction.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3304,6 +3304,9 @@ func (d *DB) compactAndWrite(
33043304
if spanPolicy.DisableValueSeparationBySuffix {
33053305
writerOpts.DisableValueBlocks = true
33063306
}
3307+
if spanPolicy.PreferFastCompression && writerOpts.Compression != block.NoCompression {
3308+
writerOpts.Compression = block.FastestCompression
3309+
}
33073310
vSep := valueSeparation
33083311
if spanPolicy.ValueStoragePolicy == ValueStorageLowReadLatency {
33093312
vSep = compact.NeverSeparateValues{}

options.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,12 @@ type ValueSeparationPolicy struct {
11861186
// SpanPolicy contains policies that can vary by key range. The zero value is
11871187
// the default value.
11881188
type SpanPolicy struct {
1189+
// Prefer a faster compression algorithm for the keys in this span.
1190+
//
1191+
// This is useful for keys that are frequently read or written but which don't
1192+
// amount to a significant amount of space.
1193+
PreferFastCompression bool
1194+
11891195
// DisableValueSeparationBySuffix disables discriminating KVs depending on
11901196
// suffix.
11911197
//

0 commit comments

Comments
 (0)