Skip to content

Commit

Permalink
zstd: Add bigger default blocks (#469)
Browse files Browse the repository at this point in the history
Keep 64K blocks for fastest, but do max size for others.

Healthy compression increase for streams.
  • Loading branch information
klauspost committed Jan 16, 2022
1 parent 8eae845 commit 22de983
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion zstd/encoder_options.go
Expand Up @@ -24,6 +24,7 @@ type encoderOptions struct {
allLitEntropy bool
customWindow bool
customALEntropy bool
customBlockSize bool
lowMem bool
dict *dict
}
Expand All @@ -33,7 +34,7 @@ func (o *encoderOptions) setDefault() {
concurrent: runtime.GOMAXPROCS(0),
crc: true,
single: nil,
blockSize: 1 << 16,
blockSize: maxCompressedBlockSize,
windowSize: 8 << 20,
level: SpeedDefault,
allLitEntropy: true,
Expand Down Expand Up @@ -106,6 +107,7 @@ func WithWindowSize(n int) EOption {
o.customWindow = true
if o.blockSize > o.windowSize {
o.blockSize = o.windowSize
o.customBlockSize = true
}
return nil
}
Expand Down Expand Up @@ -222,6 +224,9 @@ func WithEncoderLevel(l EncoderLevel) EOption {
switch o.level {
case SpeedFastest:
o.windowSize = 4 << 20
if !o.customBlockSize {
o.blockSize = 1 << 16
}
case SpeedDefault:
o.windowSize = 8 << 20
case SpeedBetterCompression:
Expand Down

0 comments on commit 22de983

Please sign in to comment.