Skip to content

Commit 2131787

Browse files
br: optimize memory allocation in waitUntilAllScheduleStopped
Signed-off-by: Artur Melanchyk <[email protected]>
1 parent 33f0727 commit 2131787

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

br/pkg/task/backup_ebs.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ func waitUntilAllScheduleStopped(ctx context.Context, cfg Config, allStores []*m
353353
defer mutex.Unlock()
354354
allRegions = append(allRegions, regions...)
355355
}
356+
357+
storeLeaderRegionsFlat := make([]*metapb.Region, 0, 100*len(allStores))
356358
for i := range allStores {
357359
store := allStores[i]
358360
if ectx.Err() != nil {
@@ -371,7 +373,7 @@ func waitUntilAllScheduleStopped(ctx context.Context, cfg Config, allStores []*m
371373
return errors.Trace(err)
372374
}
373375

374-
storeLeaderRegions := make([]*metapb.Region, 0, 100)
376+
storeLeaderRegions := storeLeaderRegionsFlat[i*100 : 0 : (i+1)*100]
375377
for {
376378
response, err2 := checkAdminClient.Recv()
377379
if err2 != nil {

0 commit comments

Comments
 (0)