mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
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:
parent
1823ab6808
commit
a406bb0288
@ -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))
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user