Browse Source
Merge pull request #3309 from guol-fnst/loading_volume
optimiz concurrency
pull/3317/head
Chris Lu
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
13 additions and
2 deletions
-
weed/storage/disk_location.go
|
|
@ -5,6 +5,7 @@ import ( |
|
|
|
"os" |
|
|
|
"path/filepath" |
|
|
|
"runtime" |
|
|
|
"strconv" |
|
|
|
"strings" |
|
|
|
"sync" |
|
|
|
"time" |
|
|
@ -208,8 +209,18 @@ func (l *DiskLocation) concurrentLoadingVolumes(needleMapKind NeedleMapKind, con |
|
|
|
func (l *DiskLocation) loadExistingVolumes(needleMapKind NeedleMapKind) { |
|
|
|
|
|
|
|
workerNum := runtime.NumCPU() |
|
|
|
if workerNum <= 10 { |
|
|
|
workerNum = 10 |
|
|
|
val, ok := os.LookupEnv("GOMAXPROCS") |
|
|
|
if ok { |
|
|
|
num, err := strconv.Atoi(val) |
|
|
|
if err != nil || num < 1 { |
|
|
|
num = 10 |
|
|
|
glog.Warningf("failed to set worker number from GOMAXPROCS , set to default:10") |
|
|
|
} |
|
|
|
workerNum = num |
|
|
|
} else { |
|
|
|
if workerNum <= 10 { |
|
|
|
workerNum = 10 |
|
|
|
} |
|
|
|
} |
|
|
|
l.concurrentLoadingVolumes(needleMapKind, workerNum) |
|
|
|
glog.V(0).Infof("Store started on dir: %s with %d volumes max %d", l.Directory, len(l.volumes), l.MaxVolumeCount) |
|
|
|