Skip to content

Commit

Permalink
txnkv: optimize batch-get by reducing overhead of backoffer (#1559)
Browse files Browse the repository at this point in the history
 

Signed-off-by: zyguan <[email protected]>
  • Loading branch information
zyguan authored Jan 16, 2025
1 parent d22ee91 commit 57aa917
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions txnkv/txnsnapshot/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,13 +360,19 @@ func (s *KVSnapshot) batchGetKeysByRegions(bo *retry.Backoffer, keys [][]byte, r
if len(batches) == 1 {
return s.batchGetSingleRegion(bo, batches[0], readTier, collectF)
}
ch := make(chan error)
for _, batch1 := range batches {
ch := make(chan error, len(batches))
bo, cancel := bo.Fork()
defer cancel()
for i, batch1 := range batches {
var backoffer *retry.Backoffer
if i == 0 {
backoffer = bo
} else {
backoffer = bo.Clone()
}
batch := batch1
go func() {
growStackForBatchGetWorker()
backoffer, cancel := bo.Fork()
defer cancel()
ch <- s.batchGetSingleRegion(backoffer, batch, readTier, collectF)
}()
}
Expand Down

0 comments on commit 57aa917

Please sign in to comment.