Skip to content

Commit

Permalink
[zstd] test low memory options
Browse files Browse the repository at this point in the history
Let's see how this affects memory usage and performance.

Related to buchgr#473.
  • Loading branch information
mostynb committed Sep 22, 2021
1 parent a914031 commit 647f07b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cache/disk/casblob/casblob.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const (

var zstdFastestLevel = zstd.WithEncoderLevel(zstd.SpeedFastest)

var encoder, _ = zstd.NewWriter(nil, zstdFastestLevel) // TODO: raise WithEncoderConcurrency ?
var decoder, _ = zstd.NewReader(nil) // TODO: raise WithDecoderConcurrency ?
var encoder, _ = zstd.NewWriter(nil, zstdFastestLevel, zstd.WithLowerEncoderMem(true)) // TODO: raise WithEncoderConcurrency ?
var decoder, _ = zstd.NewReader(nil, zstd.WithDecoderLowmem(true)) // TODO: raise WithDecoderConcurrency ?

var encoderPool = zstdpool.GetEncoderPool()
var decoderPool = zstdpool.GetDecoderPool()
Expand Down
2 changes: 1 addition & 1 deletion server/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

var blobNameSHA256 = regexp.MustCompile("^/?(.*/)?(ac/|cas/)([a-f0-9]{64})$")

var decoder, _ = zstd.NewReader(nil) // TODO: raise WithDecoderConcurrency ?
var decoder, _ = zstd.NewReader(nil, zstd.WithDecoderLowmem(true)) // TODO: raise WithDecoderConcurrency ?

// HTTPCache ...
type HTTPCache interface {
Expand Down
6 changes: 4 additions & 2 deletions utils/zstdpool/zstdpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ func GetEncoderPool() *sync.Pool {
onceEncPool.Do(func() {
encoderPool = syncpool.NewEncoderPool(
zstd.WithEncoderConcurrency(1),
zstd.WithEncoderLevel(zstd.SpeedFastest))
zstd.WithEncoderLevel(zstd.SpeedFastest),
zstd.WithLowerEncoderMem(true))
})

return encoderPool
Expand All @@ -26,7 +27,8 @@ func GetEncoderPool() *sync.Pool {
func GetDecoderPool() *sync.Pool {
onceDecPool.Do(func() {
decoderPool = syncpool.NewDecoderPool(
zstd.WithDecoderConcurrency(1))
zstd.WithDecoderConcurrency(1),
zstd.WithDecoderLowmem(true))
})

return decoderPool
Expand Down

0 comments on commit 647f07b

Please sign in to comment.