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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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))

View File

@ -52,11 +52,11 @@ type Config struct {
var DefaultKVS = config.KVS{
config.KV{
Key: Delay,
Value: "10",
Value: "2",
},
config.KV{
Key: MaxWait,
Value: "15s",
Value: "5s",
},
config.KV{
Key: Cycle,