Skip to content

Commit

Permalink
return byte slices to thrift pool in FetchBatchMetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Artoul committed Aug 8, 2019
1 parent b411f6d commit a99f7d4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/dbnode/client/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import (
xsync "github.com/m3db/m3/src/x/sync"
xtime "github.com/m3db/m3/src/x/time"

apachethrift "github.com/apache/thrift/lib/go/thrift"
"github.com/uber-go/tally"
"github.com/uber/tchannel-go/thrift"
"go.uber.org/zap"
Expand Down Expand Up @@ -2265,15 +2266,18 @@ func (s *session) streamBlocksMetadataFromPeer(
data.IncRef()
data.AppendAll(elem.ID)
data.DecRef()

clonedID := idPool.BinaryID(data)
// Return thrift bytes to pool once the ID has been copied.
apachethrift.BytesPoolPut(elem.ID)

var encodedTags checked.Bytes
if bytes := elem.EncodedTags; len(bytes) != 0 {
encodedTags = bytesPool.Get(len(bytes))
if tagBytes := elem.EncodedTags; len(tagBytes) != 0 {
encodedTags = bytesPool.Get(len(tagBytes))
encodedTags.IncRef()
encodedTags.AppendAll(bytes)
encodedTags.AppendAll(tagBytes)
encodedTags.DecRef()
// Return thrift bytes to pool once the tags have been copied.
apachethrift.BytesPoolPut(tagBytes)
}

// Error occurred retrieving block metadata, use default values
Expand Down

0 comments on commit a99f7d4

Please sign in to comment.