Skip to content

Commit

Permalink
Return zst Decoder to sync.pool when finished
Browse files Browse the repository at this point in the history
defered close for dec was broken due to shadowed variable so removed.
Added defer close in the go func that calls cache.Put
With this change we can handle higher load on the server without crash due
GOMAXPROCS.
  • Loading branch information
tobbe76 committed Aug 23, 2024
1 parent 47d8b9b commit 8c1cda8
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions server/grpc_bytestream.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import (
"github.com/buchgr/bazel-remote/v2/cache"
"github.com/buchgr/bazel-remote/v2/cache/disk/casblob"

"github.com/klauspost/compress/zstd"

"github.com/buchgr/bazel-remote/v2/utils/zstdpool"
syncpool "github.com/mostynb/zstdpool-syncpool"
)
Expand Down Expand Up @@ -367,12 +365,6 @@ func (s *grpcServer) Write(srv bytestream.ByteStream_WriteServer) error {
resourceNameChan := make(chan string, 1)

cmp := casblob.Identity
var dec *zstd.Decoder
defer func() {
if dec != nil {
dec.Close()
}
}()

go func() {
firstIteration := true
Expand Down Expand Up @@ -454,6 +446,7 @@ func (s *grpcServer) Write(srv bytestream.ByteStream_WriteServer) error {
}

go func() {
defer rc.Close()
err := s.cache.Put(srv.Context(), cache.CAS, hash, size, rc)
putResult <- err
}()
Expand Down

0 comments on commit 8c1cda8

Please sign in to comment.