mirror of
https://github.com/octoleo/restic.git
synced 2024-11-26 14:56:29 +00:00
Configure zstd encoder/decoder
This commit is contained in:
parent
2f36e044db
commit
5eb05a0afe
@ -329,7 +329,18 @@ func (r *Repository) getZstdEncoder() *zstd.Encoder {
|
|||||||
level = zstd.SpeedBestCompression
|
level = zstd.SpeedBestCompression
|
||||||
}
|
}
|
||||||
|
|
||||||
enc, err := zstd.NewWriter(nil, zstd.WithEncoderLevel(level))
|
opts := []zstd.EOption{
|
||||||
|
// Set the compression level configured.
|
||||||
|
zstd.WithEncoderLevel(level),
|
||||||
|
// Disable CRC, we have enough checks in place, makes the
|
||||||
|
// compressed data four bytes shorter.
|
||||||
|
zstd.WithEncoderCRC(false),
|
||||||
|
// Set a window of 512kbyte, so we have good lookbehind for usual
|
||||||
|
// blob sizes.
|
||||||
|
zstd.WithWindowSize(512 * 1024),
|
||||||
|
}
|
||||||
|
|
||||||
|
enc, err := zstd.NewWriter(nil, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -340,7 +351,15 @@ func (r *Repository) getZstdEncoder() *zstd.Encoder {
|
|||||||
|
|
||||||
func (r *Repository) getZstdDecoder() *zstd.Decoder {
|
func (r *Repository) getZstdDecoder() *zstd.Decoder {
|
||||||
r.allocDec.Do(func() {
|
r.allocDec.Do(func() {
|
||||||
dec, err := zstd.NewReader(nil)
|
opts := []zstd.DOption{
|
||||||
|
// Use all available cores.
|
||||||
|
zstd.WithDecoderConcurrency(0),
|
||||||
|
// Limit the maximum decompressed memory. Set to a very high,
|
||||||
|
// conservative value.
|
||||||
|
zstd.WithDecoderMaxMemory(16 * 1024 * 1024 * 1024),
|
||||||
|
}
|
||||||
|
|
||||||
|
dec, err := zstd.NewReader(nil, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user