restrict number of disks used for scanning buckets upto GOMAXPROCS (#15492)

control scanner parallelism to avoid higher CPU
usage on nodes that have more drives but an old CPU.
This commit is contained in:
Harshavardhana
2022-08-08 16:16:44 -07:00
committed by GitHub
parent 1823ab6808
commit a406bb0288
2 changed files with 10 additions and 2 deletions

View File

@@ -23,6 +23,7 @@ import (
"fmt"
"math/rand"
"os"
"runtime"
"sort"
"sync"
"time"
@@ -439,6 +440,13 @@ func (er erasureObjects) nsScanner(ctx context.Context, buckets []BucketInfo, bf
r := rand.New(rand.NewSource(time.Now().UnixNano()))
r.Shuffle(len(disks), func(i, j int) { disks[i], disks[j] = disks[j], disks[i] })
// Restrict parallelism for disk usage scanner
// upto GOMAXPROCS if GOMAXPROCS is < len(disks)
maxProcs := runtime.GOMAXPROCS(0)
if maxProcs < len(disks) {
disks = disks[:maxProcs]
}
// Start one scanner per disk
var wg sync.WaitGroup
wg.Add(len(disks))