aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chrislusf@users.noreply.github.com>2022-07-13 23:12:24 -0700
committerGitHub <noreply@github.com>2022-07-13 23:12:24 -0700
commit957c9a2eb285bfccc7da11efc0d27571c5e90947 (patch)
tree5ceaf13e4a434272e079ff14ec88734b987a514d
parent1a130125de3914c1ae00401d9a36a8d1249051d8 (diff)
parent300b383cdf7ab607c92417256dfdc5ca52ea24b0 (diff)
downloadseaweedfs-957c9a2eb285bfccc7da11efc0d27571c5e90947.tar.xz
seaweedfs-957c9a2eb285bfccc7da11efc0d27571c5e90947.zip
Merge pull request #3309 from guol-fnst/loading_volume
optimiz concurrency
-rw-r--r--weed/storage/disk_location.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/weed/storage/disk_location.go b/weed/storage/disk_location.go
index a2a63acbb..8af8ea663 100644
--- a/weed/storage/disk_location.go
+++ b/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)