diff --git a/src/dbnode/network/server/tchannelthrift/node/service.go b/src/dbnode/network/server/tchannelthrift/node/service.go index 8a7d7a0f6a..5b60d27804 100644 --- a/src/dbnode/network/server/tchannelthrift/node/service.go +++ b/src/dbnode/network/server/tchannelthrift/node/service.go @@ -808,12 +808,14 @@ func (s *service) fetchReadEncoded(ctx context.Context, // Re-use reader and id for more memory-efficient processing of // tags from doc.Metadata reader := docs.NewEncodedDocumentReader() - id := ident.NewReusableBytesID() for _, entry := range results.Map().Iter() { idx := i i++ - id.Reset(entry.Key()) + // NB(r): Use a bytes ID here so that this ID doesn't need to be + // copied by the blockRetriever in the streamRequest method when + // it checks if the ID is finalizeable or not with IsNoFinalize. + id := ident.BytesID(entry.Key()) d := entry.Value() metadata, err := docs.MetadataFromDocument(d, reader) diff --git a/src/dbnode/persist/fs/retriever.go b/src/dbnode/persist/fs/retriever.go index a64b76da83..a5bfab3511 100644 --- a/src/dbnode/persist/fs/retriever.go +++ b/src/dbnode/persist/fs/retriever.go @@ -565,9 +565,17 @@ func (r *blockRetriever) streamRequest( nsCtx namespace.Context, ) (bool, error) { req.shard = shard - // NB(r): Clone the ID as we're not positive it will stay valid throughout - // the lifecycle of the async request. - req.id = r.idPool.Clone(id) + + // NB(r): If the ID is a ident.BytesID then we can just hold + // onto this ID. + seriesID := id + if !seriesID.IsNoFinalize() { + // NB(r): Clone the ID as we're not positive it will stay valid throughout + // the lifecycle of the async request. + seriesID = r.idPool.Clone(id) + } + + req.id = seriesID req.start = startTime req.blockSize = r.blockSize